Wickham & Grolemund (2017)

Chapter 3

3.2.4 Exercises

  1. Run ggplot(data = mpg). What do you see?
library(tidyverse)
## Warning: package 'tidyverse' was built under R version 4.0.2
## Warning: replacing previous import 'ellipsis::check_dots_unnamed' by
## 'rlang::check_dots_unnamed' when loading 'tibble'
## Warning: replacing previous import 'ellipsis::check_dots_used' by
## 'rlang::check_dots_used' when loading 'tibble'
## Warning: replacing previous import 'ellipsis::check_dots_empty' by
## 'rlang::check_dots_empty' when loading 'tibble'
## ── Attaching packages ─────────────────────────────────────── tidyverse 1.3.0 ──
## ✔ ggplot2 3.3.5      ✔ purrr   0.3.4 
## ✔ tibble  3.0.4      ✔ dplyr   1.0.10
## ✔ tidyr   1.2.1      ✔ stringr 1.4.0 
## ✔ readr   1.4.0      ✔ forcats 0.5.0
## Warning: package 'ggplot2' was built under R version 4.0.2
## Warning: package 'tibble' was built under R version 4.0.2
## Warning: package 'readr' was built under R version 4.0.2
## Warning: package 'purrr' was built under R version 4.0.2
## Warning: package 'stringr' was built under R version 4.0.2
## Warning: package 'forcats' was built under R version 4.0.2
## ── Conflicts ────────────────────────────────────────── tidyverse_conflicts() ──
## ✖ dplyr::filter() masks stats::filter()
## ✖ dplyr::lag()    masks stats::lag()
ggplot(data = mpg)

This code outputs an empty plot.

  1. How many rows are in mpg? How many columns?
mpg
## # A tibble: 234 x 11
##    manufacturer model      displ  year   cyl trans drv     cty   hwy fl    class
##    <chr>        <chr>      <dbl> <int> <int> <chr> <chr> <int> <int> <chr> <chr>
##  1 audi         a4           1.8  1999     4 auto… f        18    29 p     comp…
##  2 audi         a4           1.8  1999     4 manu… f        21    29 p     comp…
##  3 audi         a4           2    2008     4 manu… f        20    31 p     comp…
##  4 audi         a4           2    2008     4 auto… f        21    30 p     comp…
##  5 audi         a4           2.8  1999     6 auto… f        16    26 p     comp…
##  6 audi         a4           2.8  1999     6 manu… f        18    26 p     comp…
##  7 audi         a4           3.1  2008     6 auto… f        18    27 p     comp…
##  8 audi         a4 quattro   1.8  1999     4 manu… 4        18    26 p     comp…
##  9 audi         a4 quattro   1.8  1999     4 auto… 4        16    25 p     comp…
## 10 audi         a4 quattro   2    2008     4 manu… 4        20    28 p     comp…
## # … with 224 more rows
nrow(mpg)
## [1] 234
ncol(mpg)
## [1] 11

There are 234 rows and 11 columns. We also know this from the 234 × 11 tibble description.

  1. What does the drv variable describe? Read the help for ?mpg to find out.
?mpg

The drv variable indicates the type of drive train, where f = front-wheel drive, r = rear wheel drive, and 4 = 4wd.

  1. Make a scatterplot of hwy vs cyl.
ggplot(data = mpg) + 
  geom_point(mapping = aes(x = cyl, y = hwy))

  1. What happens if you make a scatterplot of class vs drv? Why is the plot not useful?
ggplot(data = mpg) + 
  geom_point(mapping = aes(x = drv, y = class))

This plot isn’t useful because both variables are categorical, where class has 7 categories and drv only has 3 categories represented in this graph. Since there are limited combinations of both variables revealed through this plot, no discernible pattern can be identified.

3.3.1 Exercises

  1. What’s gone wrong with this code? Why are the points not blue?
ggplot(data = mpg) + 
  geom_point(mapping = aes(x = displ, y = hwy, color = "blue"))

The points are not blue because there is a missing close parentheses after the “aes” function. The “color=”blue” code is being read as part of the aes function, rather than part of the mapping function. To correct, the code should read as:

ggplot(data = mpg) + 
  geom_point(mapping = aes(x = displ, y = hwy), color = "blue")

  1. Which variables in mpg are categorical? Which variables are continuous? (Hint: type ?mpg to read the documentation for the dataset). How can you see this information when you run mpg?
?mpg
mpg
## # A tibble: 234 x 11
##    manufacturer model      displ  year   cyl trans drv     cty   hwy fl    class
##    <chr>        <chr>      <dbl> <int> <int> <chr> <chr> <int> <int> <chr> <chr>
##  1 audi         a4           1.8  1999     4 auto… f        18    29 p     comp…
##  2 audi         a4           1.8  1999     4 manu… f        21    29 p     comp…
##  3 audi         a4           2    2008     4 manu… f        20    31 p     comp…
##  4 audi         a4           2    2008     4 auto… f        21    30 p     comp…
##  5 audi         a4           2.8  1999     6 auto… f        16    26 p     comp…
##  6 audi         a4           2.8  1999     6 manu… f        18    26 p     comp…
##  7 audi         a4           3.1  2008     6 auto… f        18    27 p     comp…
##  8 audi         a4 quattro   1.8  1999     4 manu… 4        18    26 p     comp…
##  9 audi         a4 quattro   1.8  1999     4 auto… 4        16    25 p     comp…
## 10 audi         a4 quattro   2    2008     4 manu… 4        20    28 p     comp…
## # … with 224 more rows

The following variables are categorical: manufacturer, model, trans, drv, fl, class. The following variables are continuous: displ, year, cyl, cty, hwy. We know this based on the classification type under each variable name when mpg is ran. The categorical variables are indicated by and the continuous variables are indicated by or . Reading the descriptions from ?mpg of each variable can also help us make inferences about the type of variable.

  1. Map a continuous variable to color, size, and shape. How do these aesthetics behave differently for categorical vs. continuous variables?
ggplot(data = mpg) +
  geom_point(mapping = aes(x = displ, y = hwy, color = displ))

When mapping a cont. variable to color, the scale appears in a gradient (defaulted to blue), where the colors of the gradient represent values of the cont. variable.

ggplot(data = mpg) +
  geom_point(mapping = aes(x = displ, y = hwy, size = displ))

When mapping a cont. variable to size, we see the values of the variable represented through shape size. Here, larger values are represented as larger circles and smaller values are represented by smaller circles.

We get an error message when we try to map a continuous variable to shape. The code was not included so we could generate this html.

  1. What happens if you map the same variable to multiple aesthetics?
ggplot(data = mpg) +
  geom_point(mapping = aes(x = displ, y = hwy, color = displ, size = displ))

We see the color and size aesthetics combined in the plot; here, the points reflect both the size scale and color gradient corresponding to the values of the cont. variable.

  1. What does the stroke aesthetic do? What shapes does it work with? (Hint: use ?geom_point)

Stroke adjusts the thickness of the border for shapes plotted. It only works for shapes 21-24. The larger the number, the larger in area of the border is. A sample is below:

?geom_point

ggplot(data = mpg) +
  geom_point(mapping = aes(x = displ, y = hwy), shape = 24,
             fill = 'blue', size = 3, stroke = 5, color = 'red')

  1. What happens if you map an aesthetic to something other than a variable name, like aes(colour = displ < 5)? Note, you’ll also need to specify x and y.
ggplot(data = mpg) +
  geom_point(mapping = aes(x = displ, y = hwy, color = displ < 5))

Using aes(colour = displ < 5) categorizes the displ variable dichotomously into “True” and “False” categories, where values <5 fall under “True” and everything else (values > or = 5) falls under “False”. These two categories are color-coded with different colors (here, blue = true and red = false).

3.5.1 Exercises 1. What happens if you facet on a continuous variable?

ggplot(data = mpg) + 
  geom_point(mapping = aes(x = displ, y = hwy)) + 
  facet_wrap(~cty)

When you facet on a continuous variable, it facets according to each level of the variable represented in the dataset. I’d imagine this would not be helpful if there were many levels/values of a continuous variable represented in the data set. Categorical variables tend to have fewer levels, and therefore faceting could be more useful.

  1. What do the empty cells in plot with facet_grid(drv ~ cyl) mean? How do they relate to this plot?
ggplot(data = mpg) +
  geom_point(mapping = aes(x = displ, y= hwy)) + 
  facet_grid(drv ~ cyl)

The empty grids indicate that there are no observations for that combination of cyl and drv.

  1. What plots does the following code make? What does . do?
ggplot(data = mpg) + 
  geom_point(mapping = aes(x = displ, y = hwy)) +
  facet_grid(drv ~ .)

ggplot(data = mpg) + 
  geom_point(mapping = aes(x = displ, y = hwy)) +
  facet_grid(. ~ cyl)

The first plot plots hwy vs. displ, where the rows are facetted by drv. The second plot plots hwy vs. displ, where the columns are facetted by cyl.

  1. Take the first faceted plot in this section. What are the advantages to using faceting instead of the colour aesthetic? What are the disadvantages? How might the balance change if you had a larger dataset?
ggplot(data = mpg) + 
  geom_point(mapping = aes(x = displ, y = hwy)) + 
  facet_wrap(~ class, nrow = 2)

A main advantage of using facetting instead of coloring is it allows for more direct interpretation of the plot based on the facetted variable, rather than having to refer back and forth to the legend vs. plot, and having to mentally keep track of what each color represents. It also minimizes the noise/busyness of having many colors on one plot.

  1. Read ?facet_wrap. What does nrow do? What does ncol do? What other options control the layout of the individual panels? Why doesn’t facet_grid() have nrow and ncol arguments? For the function facet_wrap(), nrow and ncol allow you to indicate the number of rows and columns. facet_grid() does not have nrow and ncol since the number of rows and columns are set by to the number of unique levels in the row/column variables.

  2. When using facet_grid() you should usually put the variable with more unique levels in the columns. Why? When facetting a plot, it is usually easier to make comparisons of plots when they are side by side (i.e., facetted by columns), rather than making comparisons of plots that are above and below each other. The fact that the DV typically sits on the y-axis contributes to why the former is easier for interpretation than the latter.

3.6.1 Exercises

  1. What geom would you use to draw a line chart? A boxplot? A histogram? An area chart? I’d use the following to draw each respectively: geom_line(), geom_boxplot(), geom_histogram(), and geom_area().

  2. Run this code in your head and predict what the output will look like. Then, run the code in R and check your predictions.

I predicted this graph would illustrate hwy vs. displ, where the points are color-coded by the categories of drv. geom_smooth() will draw a different line, with a different linetype, for each unique value of the variable that’s mapped, so we should see 3 unique lines representing the levels of drv, each abiding to the color-coding scheme.

ggplot(data = mpg, mapping = aes(x = displ, y = hwy, color = drv)) + 
  geom_point() + 
  geom_smooth(se = FALSE)
## `geom_smooth()` using method = 'loess' and formula 'y ~ x'

  1. What does show.legend = FALSE do? What happens if you remove it? Why do you think I used it earlier in the chapter?

show.legend = FALSE hides the legend on the right hand side of the plot, when a variable is mapped to an aesthetic. show.legend is defaulted to = TRUE. It was used earlier in the chapter to hide the legend of the example plot.

  1. What does the se argument to geom_smooth() do?
?geom_smooth

The se argument displays the confidence interval around smooth (TRUE by default).

  1. Will these two graphs look different? Why/why not?
ggplot(data = mpg, mapping = aes(x = displ, y = hwy)) + 
  geom_point() + 
  geom_smooth()
## `geom_smooth()` using method = 'loess' and formula 'y ~ x'

ggplot() + 
  geom_point(data = mpg, mapping = aes(x = displ, y = hwy)) + 
  geom_smooth(data = mpg, mapping = aes(x = displ, y = hwy))
## `geom_smooth()` using method = 'loess' and formula 'y ~ x'

No, these graphs will look identical because they are asking for the same output, just written in different ways. In the first code, the plot is mapped and then “geomed”. In the second code, the plots are mapped and defined within each geom.

  1. Recreate the R code necessary to generate the following graphs.
ggplot(data = mpg, mapping = aes(y = hwy, x = displ)) + 
  geom_point() +
  geom_smooth(se = FALSE)
## `geom_smooth()` using method = 'loess' and formula 'y ~ x'

ggplot(data = mpg, mapping = aes(y = hwy, x = displ)) + 
  geom_point() +
  geom_smooth(mapping = aes(group = drv), se = FALSE, show.legend = FALSE)
## `geom_smooth()` using method = 'loess' and formula 'y ~ x'

ggplot(data = mpg, mapping = aes(y = hwy, x = displ)) + 
  geom_point(mapping = aes(color = drv)) +
  geom_smooth(mapping = aes(color = drv, group = drv), se = FALSE)
## `geom_smooth()` using method = 'loess' and formula 'y ~ x'

ggplot(data = mpg, mapping = aes(y = hwy, x = displ)) + 
  geom_point(mapping = aes(color = drv)) +
  geom_smooth(se = FALSE)
## `geom_smooth()` using method = 'loess' and formula 'y ~ x'

ggplot(data = mpg, mapping = aes(y = hwy, x = displ)) + 
  geom_point(mapping = aes(color = drv)) +
  geom_smooth(mapping = aes(linetype = drv), se = FALSE)
## `geom_smooth()` using method = 'loess' and formula 'y ~ x'

ggplot(data = mpg, mapping = aes(y = hwy, x = displ)) + 
  geom_point(mapping = aes(fill = drv), color = 'white', stroke = 3, shape = 21, size = 4)

3.7.1 Exercises

1.What is the default geom associated with stat_summary()? How could you rewrite the previous plot to use that geom function instead of the stat function?

The default geom associated with stat_summary() is geom_pointrange(). The previous plot can be rewritten with the following code:

diamonds %>% group_by(cut) %>% summarize(median_y = median(depth),
                                         min_y = min(depth),
                                         max_y = max(depth)) %>%
  ggplot() +
  geom_pointrange(mapping = aes(x = cut, y = median_y, ymin = min_y, ymax = max_y)) +
  labs(y = 'depth')

  1. What does geom_col() do? How is it different to geom_bar()?

geom_col() and geom_bar() create bar charts. geom_bar() makes the height of the bar proportional to the number of cases in each group. On the other hand, geom_col() makes the heights of the bars to represent values in the data. The heights of the bars represent the values in the data. geom_bar() uses stat_count() by default and counts the number of cases at each x position, while geom_col() uses stat_identity() and leaves the data as is.

  1. Most geoms and stats come in pairs that are almost always used in concert. Read through the documentation and make a list of all the pairs. What do they have in common?

Geom & Stats Pairs: geom_bar() & stat_count() geom_bin2d() & stat_bin_2d() geom_boxplot() & stat_boxplot() geom_contour_filled() & stat_contour_filled() geom_contour() & stat_contour() geom_count() & stat_sum() geom_density_2d() & stat_density_2d() geom_density() & stat_density() geom_dotplot() & stat_bindot() geom_function() & stat_function() geom_sf() & stat_sf() geom_sf() & stat_sf() geom_smooth() & stat_smooth() geom_violin() & stat_ydensity() geom_hex() & stat_bin_hex() geom_qq_line() & stat_qq_line() geom_qq() & stat_qq() geom_quantile() & stat_quantile() The names of the geoms and stats pairs tend to be the same (e.g., geom_boxplot() and stat_boxplot()).

4.What variables does stat_smooth() compute? What parameters control its behaviour?

stat_smooth() calculates the following variables: y or x : predicted value ymin or xmin: lower pointwise confidence interval around the mean ymax or xmax : upper pointwise confidence interval around the mean se: standard error

The following parameters control the behavior: method formula se na.rm method.args (see ?stat_smooth() for list under arguments)

  1. In our proportion bar chart, we need to set group = 1. Why? In other words what is the problem with these two graphs?

In the proportion bar chart, the bars in the plot will have the same height ( a height of 1), if the group is not set to group = 1. Thus, the problem with the two graphs is that the plots have the same height, since geom_bar() makes the height of the bar proportional to the number of cases in each group. Setting group=1 will correct for this.

3.8.1 Exercises 1. What is the problem with this plot? How could you improve it?

ggplot(data = mpg, mapping = aes(x = cty, y = hwy)) +
  geom_point()

In this plot, many points of hwy and cty overlap each other. This problem is known as overplotting. You can use a jitter position adjustment to decrease overplotting. position = “jitter” adds a small amount of random noise to each point and therefore spreads the points out more.

ggplot(data = mpg, mapping = aes(x = cty, y = hwy)) +
  geom_point(position = "jitter")

2.What parameters to geom_jitter() control the amount of jittering?

There are two arguments to jitter that control the amount of jittering: width, which controls the amount of horizontal displacement height, which controls the amount of vertical displacement The default introduces noise in both directions.

  1. Compare and contrast geom_jitter() with geom_count().

geom_jitter() adds a small amount of random noise to each point to reduce overplotting. Thus, the locations of x and y are changed slightly. geom_count() does not change the location of x and y. If there are many points on one location, then the size of the points will increase. In other words, values with more observations will be larger than those with fewer observations.

4.What’s the default position adjustment for geom_boxplot()? Create a visualisation of the mpg dataset that demonstrates it.

The default position adjustment for geom_boxplot() is “dodge2”. You can see in the below that there are multiple boxplots for each level fo the DV (drv), and dodge2 positions the boxplots so you can see each and they are not overlapping.

ggplot(data = mpg, aes(x = hwy, y = drv, color = class)) +
  geom_boxplot()

3.9.1 Exercises 1.Turn a stacked bar chart into a pie chart using coord_polar().

ggplot(data = mpg) + 
  geom_bar(mapping = aes(x = drv, fill = manufacturer))+
  coord_polar()

2.What does labs() do? Read the documentation.

labs() lets you edit the axis, plot, and legend labels.

3.What’s the difference between coord_quickmap() and coord_map()?

The coord_quickmap() function projects a portion of the earth, which is approximately spherical, onto a flat 2D plane. This function does not preserve straight lines. On the other hand, coord_quickmap() is a quick approximation that does preserve straight lines.

4.What does the plot below tell you about the relationship between city and highway mpg? Why is coord_fixed() important? What does geom_abline() do?

ggplot(data = mpg, mapping = aes(x = cty, y = hwy)) +
  geom_point() + 
  geom_abline() +
  coord_fixed()

The plot indicates a positive linear relationship between hwy and cty (as cty increases, hwy increases). geom_abline() adds the diagonal line to the plot, with a slope of 1. This allows for us to gauge the approximate slope of the relationship between hwy and cty, according to this reference line; the slope of the positive linear relationship between hwy and cty is close to 1 (a unit increase in cty is associated with a unit increase in hwy).

coord_fixed forces a specified ratio between the physical representation of data units on the axes.The ratio represents the number of units on the y-axis equivalent to one unit on the x-axis. The default is ratio = 1 and ensures that one unit on the x-axis is the same length as one unit on the y-axis. Here, it allows us to more accurately reference the line from geom_abline() and infer the slope of 1.

Chapter 4

4.4 Exercises 1. Why does this code not work?

The code doesn’t work because in the second line, there is a typo. “my_varıable” needs to be corrected to “my_variable” to run seamlessly. See the corrected code below:

my_variable <- 10
my_variable
## [1] 10
  1. Tweak each of the following R commands so that they run correctly: See corrections below:
library(tidyverse)

ggplot(data = mpg) + 
  geom_point(mapping = aes(x = displ, y = hwy))

filter(mpg, cyl == 8)
## # A tibble: 70 x 11
##    manufacturer model      displ  year   cyl trans drv     cty   hwy fl    class
##    <chr>        <chr>      <dbl> <int> <int> <chr> <chr> <int> <int> <chr> <chr>
##  1 audi         a6 quattro   4.2  2008     8 auto… 4        16    23 p     mids…
##  2 chevrolet    c1500 sub…   5.3  2008     8 auto… r        14    20 r     suv  
##  3 chevrolet    c1500 sub…   5.3  2008     8 auto… r        11    15 e     suv  
##  4 chevrolet    c1500 sub…   5.3  2008     8 auto… r        14    20 r     suv  
##  5 chevrolet    c1500 sub…   5.7  1999     8 auto… r        13    17 r     suv  
##  6 chevrolet    c1500 sub…   6    2008     8 auto… r        12    17 r     suv  
##  7 chevrolet    corvette     5.7  1999     8 manu… r        16    26 p     2sea…
##  8 chevrolet    corvette     5.7  1999     8 auto… r        15    23 p     2sea…
##  9 chevrolet    corvette     6.2  2008     8 manu… r        16    26 p     2sea…
## 10 chevrolet    corvette     6.2  2008     8 auto… r        15    25 p     2sea…
## # … with 60 more rows
filter(diamonds, carat > 3)
## # A tibble: 32 x 10
##    carat cut     color clarity depth table price     x     y     z
##    <dbl> <ord>   <ord> <ord>   <dbl> <dbl> <int> <dbl> <dbl> <dbl>
##  1  3.01 Premium I     I1       62.7    58  8040  9.1   8.97  5.67
##  2  3.11 Fair    J     I1       65.9    57  9823  9.15  9.02  5.98
##  3  3.01 Premium F     I1       62.2    56  9925  9.24  9.13  5.73
##  4  3.05 Premium E     I1       60.9    58 10453  9.26  9.25  5.66
##  5  3.02 Fair    I     I1       65.2    56 10577  9.11  9.02  5.91
##  6  3.01 Fair    H     I1       56.1    62 10761  9.54  9.38  5.31
##  7  3.65 Fair    H     I1       67.1    53 11668  9.53  9.48  6.38
##  8  3.24 Premium H     I1       62.1    58 12300  9.44  9.4   5.85
##  9  3.22 Ideal   I     I1       62.6    55 12545  9.49  9.42  5.92
## 10  3.5  Ideal   H     I1       62.8    57 12587  9.65  9.59  6.03
## # … with 22 more rows
  1. Press Alt + Shift + K. What happens? How can you get to the same place using the menus?

The Keyboard Shortcut Quick Reference appears. Using the menus, click Help, then Keyboard Shortcuts Help.

##Chapter 5

Install data

library(nycflights13)
## Warning: package 'nycflights13' was built under R version 4.0.2
colnames(flights)
##  [1] "year"           "month"          "day"            "dep_time"      
##  [5] "sched_dep_time" "dep_delay"      "arr_time"       "sched_arr_time"
##  [9] "arr_delay"      "carrier"        "flight"         "tailnum"       
## [13] "origin"         "dest"           "air_time"       "distance"      
## [17] "hour"           "minute"         "time_hour"

5.2.4 Exercises

  1. Find all flights that
#1. Had an arrival delay of two or more hours
filter(flights, arr_delay >= 120)
## # A tibble: 10,200 x 19
##     year month   day dep_time sched_de…¹ dep_d…² arr_t…³ sched…⁴ arr_d…⁵ carrier
##    <int> <int> <int>    <int>      <int>   <dbl>   <int>   <int>   <dbl> <chr>  
##  1  2013     1     1      811        630     101    1047     830     137 MQ     
##  2  2013     1     1      848       1835     853    1001    1950     851 MQ     
##  3  2013     1     1      957        733     144    1056     853     123 UA     
##  4  2013     1     1     1114        900     134    1447    1222     145 UA     
##  5  2013     1     1     1505       1310     115    1638    1431     127 EV     
##  6  2013     1     1     1525       1340     105    1831    1626     125 B6     
##  7  2013     1     1     1549       1445      64    1912    1656     136 EV     
##  8  2013     1     1     1558       1359     119    1718    1515     123 EV     
##  9  2013     1     1     1732       1630      62    2028    1825     123 EV     
## 10  2013     1     1     1803       1620     103    2008    1750     138 MQ     
## # … with 10,190 more rows, 9 more variables: flight <int>, tailnum <chr>,
## #   origin <chr>, dest <chr>, air_time <dbl>, distance <dbl>, hour <dbl>,
## #   minute <dbl>, time_hour <dttm>, and abbreviated variable names
## #   ¹​sched_dep_time, ²​dep_delay, ³​arr_time, ⁴​sched_arr_time, ⁵​arr_delay
#2 Flew to Houston (IAH or HOU)
filter(flights, dest == "IAH" | dest == "HOU")
## # A tibble: 9,313 x 19
##     year month   day dep_time sched_de…¹ dep_d…² arr_t…³ sched…⁴ arr_d…⁵ carrier
##    <int> <int> <int>    <int>      <int>   <dbl>   <int>   <int>   <dbl> <chr>  
##  1  2013     1     1      517        515       2     830     819      11 UA     
##  2  2013     1     1      533        529       4     850     830      20 UA     
##  3  2013     1     1      623        627      -4     933     932       1 UA     
##  4  2013     1     1      728        732      -4    1041    1038       3 UA     
##  5  2013     1     1      739        739       0    1104    1038      26 UA     
##  6  2013     1     1      908        908       0    1228    1219       9 UA     
##  7  2013     1     1     1028       1026       2    1350    1339      11 UA     
##  8  2013     1     1     1044       1045      -1    1352    1351       1 UA     
##  9  2013     1     1     1114        900     134    1447    1222     145 UA     
## 10  2013     1     1     1205       1200       5    1503    1505      -2 UA     
## # … with 9,303 more rows, 9 more variables: flight <int>, tailnum <chr>,
## #   origin <chr>, dest <chr>, air_time <dbl>, distance <dbl>, hour <dbl>,
## #   minute <dbl>, time_hour <dttm>, and abbreviated variable names
## #   ¹​sched_dep_time, ²​dep_delay, ³​arr_time, ⁴​sched_arr_time, ⁵​arr_delay
#3 Were operated by United, American, or Delta
filter(flights, carrier %in% c("UA", "AA", "DL"))
## # A tibble: 139,504 x 19
##     year month   day dep_time sched_de…¹ dep_d…² arr_t…³ sched…⁴ arr_d…⁵ carrier
##    <int> <int> <int>    <int>      <int>   <dbl>   <int>   <int>   <dbl> <chr>  
##  1  2013     1     1      517        515       2     830     819      11 UA     
##  2  2013     1     1      533        529       4     850     830      20 UA     
##  3  2013     1     1      542        540       2     923     850      33 AA     
##  4  2013     1     1      554        600      -6     812     837     -25 DL     
##  5  2013     1     1      554        558      -4     740     728      12 UA     
##  6  2013     1     1      558        600      -2     753     745       8 AA     
##  7  2013     1     1      558        600      -2     924     917       7 UA     
##  8  2013     1     1      558        600      -2     923     937     -14 UA     
##  9  2013     1     1      559        600      -1     941     910      31 AA     
## 10  2013     1     1      559        600      -1     854     902      -8 UA     
## # … with 139,494 more rows, 9 more variables: flight <int>, tailnum <chr>,
## #   origin <chr>, dest <chr>, air_time <dbl>, distance <dbl>, hour <dbl>,
## #   minute <dbl>, time_hour <dttm>, and abbreviated variable names
## #   ¹​sched_dep_time, ²​dep_delay, ³​arr_time, ⁴​sched_arr_time, ⁵​arr_delay
#4 Departed in summer (July, August, and September)
filter(flights, month %in% 7:9)
## # A tibble: 86,326 x 19
##     year month   day dep_time sched_de…¹ dep_d…² arr_t…³ sched…⁴ arr_d…⁵ carrier
##    <int> <int> <int>    <int>      <int>   <dbl>   <int>   <int>   <dbl> <chr>  
##  1  2013     7     1        1       2029     212     236    2359     157 B6     
##  2  2013     7     1        2       2359       3     344     344       0 B6     
##  3  2013     7     1       29       2245     104     151       1     110 B6     
##  4  2013     7     1       43       2130     193     322      14     188 B6     
##  5  2013     7     1       44       2150     174     300     100     120 AA     
##  6  2013     7     1       46       2051     235     304    2358     186 B6     
##  7  2013     7     1       48       2001     287     308    2305     243 VX     
##  8  2013     7     1       58       2155     183     335      43     172 B6     
##  9  2013     7     1      100       2146     194     327      30     177 B6     
## 10  2013     7     1      100       2245     135     337     135     122 B6     
## # … with 86,316 more rows, 9 more variables: flight <int>, tailnum <chr>,
## #   origin <chr>, dest <chr>, air_time <dbl>, distance <dbl>, hour <dbl>,
## #   minute <dbl>, time_hour <dttm>, and abbreviated variable names
## #   ¹​sched_dep_time, ²​dep_delay, ³​arr_time, ⁴​sched_arr_time, ⁵​arr_delay
#5 Arrived more than two hours late, but didn’t leave late
filter(flights, arr_delay > 120 & dep_delay <= 0)
## # A tibble: 29 x 19
##     year month   day dep_time sched_de…¹ dep_d…² arr_t…³ sched…⁴ arr_d…⁵ carrier
##    <int> <int> <int>    <int>      <int>   <dbl>   <int>   <int>   <dbl> <chr>  
##  1  2013     1    27     1419       1420      -1    1754    1550     124 MQ     
##  2  2013    10     7     1350       1350       0    1736    1526     130 EV     
##  3  2013    10     7     1357       1359      -2    1858    1654     124 AA     
##  4  2013    10    16      657        700      -3    1258    1056     122 B6     
##  5  2013    11     1      658        700      -2    1329    1015     194 VX     
##  6  2013     3    18     1844       1847      -3      39    2219     140 UA     
##  7  2013     4    17     1635       1640      -5    2049    1845     124 MQ     
##  8  2013     4    18      558        600      -2    1149     850     179 AA     
##  9  2013     4    18      655        700      -5    1213     950     143 AA     
## 10  2013     5    22     1827       1830      -3    2217    2010     127 MQ     
## # … with 19 more rows, 9 more variables: flight <int>, tailnum <chr>,
## #   origin <chr>, dest <chr>, air_time <dbl>, distance <dbl>, hour <dbl>,
## #   minute <dbl>, time_hour <dttm>, and abbreviated variable names
## #   ¹​sched_dep_time, ²​dep_delay, ³​arr_time, ⁴​sched_arr_time, ⁵​arr_delay
#6 Were delayed by at least an hour, but made up over 30 minutes in flight
filter(flights, dep_delay >= 60 & (dep_delay - arr_delay > 30))
## # A tibble: 1,844 x 19
##     year month   day dep_time sched_de…¹ dep_d…² arr_t…³ sched…⁴ arr_d…⁵ carrier
##    <int> <int> <int>    <int>      <int>   <dbl>   <int>   <int>   <dbl> <chr>  
##  1  2013     1     1     2205       1720     285      46    2040     246 AA     
##  2  2013     1     1     2326       2130     116     131      18      73 B6     
##  3  2013     1     3     1503       1221     162    1803    1555     128 UA     
##  4  2013     1     3     1839       1700      99    2056    1950      66 AA     
##  5  2013     1     3     1850       1745      65    2148    2120      28 AA     
##  6  2013     1     3     1941       1759     102    2246    2139      67 UA     
##  7  2013     1     3     1950       1845      65    2228    2227       1 B6     
##  8  2013     1     3     2015       1915      60    2135    2111      24 9E     
##  9  2013     1     3     2257       2000     177      45    2224     141 9E     
## 10  2013     1     4     1917       1700     137    2135    1950     105 AA     
## # … with 1,834 more rows, 9 more variables: flight <int>, tailnum <chr>,
## #   origin <chr>, dest <chr>, air_time <dbl>, distance <dbl>, hour <dbl>,
## #   minute <dbl>, time_hour <dttm>, and abbreviated variable names
## #   ¹​sched_dep_time, ²​dep_delay, ³​arr_time, ⁴​sched_arr_time, ⁵​arr_delay
#7 Departed between midnight and 6am (inclusive)
filter(flights, dep_time >= 0000 & dep_time <= 0600)
## # A tibble: 9,344 x 19
##     year month   day dep_time sched_de…¹ dep_d…² arr_t…³ sched…⁴ arr_d…⁵ carrier
##    <int> <int> <int>    <int>      <int>   <dbl>   <int>   <int>   <dbl> <chr>  
##  1  2013     1     1      517        515       2     830     819      11 UA     
##  2  2013     1     1      533        529       4     850     830      20 UA     
##  3  2013     1     1      542        540       2     923     850      33 AA     
##  4  2013     1     1      544        545      -1    1004    1022     -18 B6     
##  5  2013     1     1      554        600      -6     812     837     -25 DL     
##  6  2013     1     1      554        558      -4     740     728      12 UA     
##  7  2013     1     1      555        600      -5     913     854      19 B6     
##  8  2013     1     1      557        600      -3     709     723     -14 EV     
##  9  2013     1     1      557        600      -3     838     846      -8 B6     
## 10  2013     1     1      558        600      -2     753     745       8 AA     
## # … with 9,334 more rows, 9 more variables: flight <int>, tailnum <chr>,
## #   origin <chr>, dest <chr>, air_time <dbl>, distance <dbl>, hour <dbl>,
## #   minute <dbl>, time_hour <dttm>, and abbreviated variable names
## #   ¹​sched_dep_time, ²​dep_delay, ³​arr_time, ⁴​sched_arr_time, ⁵​arr_delay
  1. Another useful dplyr filtering helper is between(). What does it do? Can you use it to simplify the code needed to answer the previous challenges?

Between indicates the lower and upper cut of the values we are looking for. For example, we can say x is between 7 and 9 if 7<x<9 See below for the simplified code

filter(flights, between(month, 7, 9))
## # A tibble: 86,326 x 19
##     year month   day dep_time sched_de…¹ dep_d…² arr_t…³ sched…⁴ arr_d…⁵ carrier
##    <int> <int> <int>    <int>      <int>   <dbl>   <int>   <int>   <dbl> <chr>  
##  1  2013     7     1        1       2029     212     236    2359     157 B6     
##  2  2013     7     1        2       2359       3     344     344       0 B6     
##  3  2013     7     1       29       2245     104     151       1     110 B6     
##  4  2013     7     1       43       2130     193     322      14     188 B6     
##  5  2013     7     1       44       2150     174     300     100     120 AA     
##  6  2013     7     1       46       2051     235     304    2358     186 B6     
##  7  2013     7     1       48       2001     287     308    2305     243 VX     
##  8  2013     7     1       58       2155     183     335      43     172 B6     
##  9  2013     7     1      100       2146     194     327      30     177 B6     
## 10  2013     7     1      100       2245     135     337     135     122 B6     
## # … with 86,316 more rows, 9 more variables: flight <int>, tailnum <chr>,
## #   origin <chr>, dest <chr>, air_time <dbl>, distance <dbl>, hour <dbl>,
## #   minute <dbl>, time_hour <dttm>, and abbreviated variable names
## #   ¹​sched_dep_time, ²​dep_delay, ³​arr_time, ⁴​sched_arr_time, ⁵​arr_delay
  1. How many flights have a missing dep_time? What other variables are missing? What might these rows represent?
summary(flights$dep_time) #8255 missing
##    Min. 1st Qu.  Median    Mean 3rd Qu.    Max.    NA's 
##       1     907    1401    1349    1744    2400    8255
# What other variables are missing
filter(flights, is.na(dep_time))
## # A tibble: 8,255 x 19
##     year month   day dep_time sched_de…¹ dep_d…² arr_t…³ sched…⁴ arr_d…⁵ carrier
##    <int> <int> <int>    <int>      <int>   <dbl>   <int>   <int>   <dbl> <chr>  
##  1  2013     1     1       NA       1630      NA      NA    1815      NA EV     
##  2  2013     1     1       NA       1935      NA      NA    2240      NA AA     
##  3  2013     1     1       NA       1500      NA      NA    1825      NA AA     
##  4  2013     1     1       NA        600      NA      NA     901      NA B6     
##  5  2013     1     2       NA       1540      NA      NA    1747      NA EV     
##  6  2013     1     2       NA       1620      NA      NA    1746      NA EV     
##  7  2013     1     2       NA       1355      NA      NA    1459      NA EV     
##  8  2013     1     2       NA       1420      NA      NA    1644      NA EV     
##  9  2013     1     2       NA       1321      NA      NA    1536      NA EV     
## 10  2013     1     2       NA       1545      NA      NA    1910      NA AA     
## # … with 8,245 more rows, 9 more variables: flight <int>, tailnum <chr>,
## #   origin <chr>, dest <chr>, air_time <dbl>, distance <dbl>, hour <dbl>,
## #   minute <dbl>, time_hour <dttm>, and abbreviated variable names
## #   ¹​sched_dep_time, ²​dep_delay, ³​arr_time, ⁴​sched_arr_time, ⁵​arr_delay
#arrival time is also missing
#What might these rows represent?
#these are flights that did not happen/ have not taken place
  1. Why is NA ^ 0 not missing? Because all number ^ 0 equals 1

Why is NA | TRUE not missing? This is a “or” statement, so TRUE can be the value regardless of NA

Why is FALSE & NA not missing? This is an “and” statement, anything with FALSE will be false

Can you figure out the general rule? (NA * 0 is a tricky counterexample!) The general rule is that if a rule applies to all numbers, it will apply to NA The rules for multiplication by 0 is not applicable to infinite numbers

5.3.1 Exercises

  1. How could you use arrange() to sort all missing values to the start? (Hint: use is.na()).
arrange(flights, desc(is.na(dep_time)), dep_time)
## # A tibble: 336,776 x 19
##     year month   day dep_time sched_de…¹ dep_d…² arr_t…³ sched…⁴ arr_d…⁵ carrier
##    <int> <int> <int>    <int>      <int>   <dbl>   <int>   <int>   <dbl> <chr>  
##  1  2013     1     1       NA       1630      NA      NA    1815      NA EV     
##  2  2013     1     1       NA       1935      NA      NA    2240      NA AA     
##  3  2013     1     1       NA       1500      NA      NA    1825      NA AA     
##  4  2013     1     1       NA        600      NA      NA     901      NA B6     
##  5  2013     1     2       NA       1540      NA      NA    1747      NA EV     
##  6  2013     1     2       NA       1620      NA      NA    1746      NA EV     
##  7  2013     1     2       NA       1355      NA      NA    1459      NA EV     
##  8  2013     1     2       NA       1420      NA      NA    1644      NA EV     
##  9  2013     1     2       NA       1321      NA      NA    1536      NA EV     
## 10  2013     1     2       NA       1545      NA      NA    1910      NA AA     
## # … with 336,766 more rows, 9 more variables: flight <int>, tailnum <chr>,
## #   origin <chr>, dest <chr>, air_time <dbl>, distance <dbl>, hour <dbl>,
## #   minute <dbl>, time_hour <dttm>, and abbreviated variable names
## #   ¹​sched_dep_time, ²​dep_delay, ³​arr_time, ⁴​sched_arr_time, ⁵​arr_delay
  1. Sort flights to find the most delayed flights
arrange(flights, desc(dep_delay))
## # A tibble: 336,776 x 19
##     year month   day dep_time sched_de…¹ dep_d…² arr_t…³ sched…⁴ arr_d…⁵ carrier
##    <int> <int> <int>    <int>      <int>   <dbl>   <int>   <int>   <dbl> <chr>  
##  1  2013     1     9      641        900    1301    1242    1530    1272 HA     
##  2  2013     6    15     1432       1935    1137    1607    2120    1127 MQ     
##  3  2013     1    10     1121       1635    1126    1239    1810    1109 MQ     
##  4  2013     9    20     1139       1845    1014    1457    2210    1007 AA     
##  5  2013     7    22      845       1600    1005    1044    1815     989 MQ     
##  6  2013     4    10     1100       1900     960    1342    2211     931 DL     
##  7  2013     3    17     2321        810     911     135    1020     915 DL     
##  8  2013     6    27      959       1900     899    1236    2226     850 DL     
##  9  2013     7    22     2257        759     898     121    1026     895 DL     
## 10  2013    12     5      756       1700     896    1058    2020     878 AA     
## # … with 336,766 more rows, 9 more variables: flight <int>, tailnum <chr>,
## #   origin <chr>, dest <chr>, air_time <dbl>, distance <dbl>, hour <dbl>,
## #   minute <dbl>, time_hour <dttm>, and abbreviated variable names
## #   ¹​sched_dep_time, ²​dep_delay, ³​arr_time, ⁴​sched_arr_time, ⁵​arr_delay
#Find the flights that left earliest
arrange(flights, year, month, day, dep_time)
## # A tibble: 336,776 x 19
##     year month   day dep_time sched_de…¹ dep_d…² arr_t…³ sched…⁴ arr_d…⁵ carrier
##    <int> <int> <int>    <int>      <int>   <dbl>   <int>   <int>   <dbl> <chr>  
##  1  2013     1     1      517        515       2     830     819      11 UA     
##  2  2013     1     1      533        529       4     850     830      20 UA     
##  3  2013     1     1      542        540       2     923     850      33 AA     
##  4  2013     1     1      544        545      -1    1004    1022     -18 B6     
##  5  2013     1     1      554        600      -6     812     837     -25 DL     
##  6  2013     1     1      554        558      -4     740     728      12 UA     
##  7  2013     1     1      555        600      -5     913     854      19 B6     
##  8  2013     1     1      557        600      -3     709     723     -14 EV     
##  9  2013     1     1      557        600      -3     838     846      -8 B6     
## 10  2013     1     1      558        600      -2     753     745       8 AA     
## # … with 336,766 more rows, 9 more variables: flight <int>, tailnum <chr>,
## #   origin <chr>, dest <chr>, air_time <dbl>, distance <dbl>, hour <dbl>,
## #   minute <dbl>, time_hour <dttm>, and abbreviated variable names
## #   ¹​sched_dep_time, ²​dep_delay, ³​arr_time, ⁴​sched_arr_time, ⁵​arr_delay
  1. Sort flights to find the fastest (highest speed) flights.
arrange(flights, desc(distance/air_time))
## # A tibble: 336,776 x 19
##     year month   day dep_time sched_de…¹ dep_d…² arr_t…³ sched…⁴ arr_d…⁵ carrier
##    <int> <int> <int>    <int>      <int>   <dbl>   <int>   <int>   <dbl> <chr>  
##  1  2013     5    25     1709       1700       9    1923    1937     -14 DL     
##  2  2013     7     2     1558       1513      45    1745    1719      26 EV     
##  3  2013     5    13     2040       2025      15    2225    2226      -1 EV     
##  4  2013     3    23     1914       1910       4    2045    2043       2 EV     
##  5  2013     1    12     1559       1600      -1    1849    1917     -28 DL     
##  6  2013    11    17      650        655      -5    1059    1150     -51 DL     
##  7  2013     2    21     2355       2358      -3     412     438     -26 B6     
##  8  2013    11    17      759        800      -1    1212    1255     -43 AA     
##  9  2013    11    16     2003       1925      38      17      36     -19 DL     
## 10  2013    11    16     2349       2359     -10     402     440     -38 B6     
## # … with 336,766 more rows, 9 more variables: flight <int>, tailnum <chr>,
## #   origin <chr>, dest <chr>, air_time <dbl>, distance <dbl>, hour <dbl>,
## #   minute <dbl>, time_hour <dttm>, and abbreviated variable names
## #   ¹​sched_dep_time, ²​dep_delay, ³​arr_time, ⁴​sched_arr_time, ⁵​arr_delay
  1. Which flights travelled the farthest? Which travelled the shortest?
arrange(flights, desc(distance))
## # A tibble: 336,776 x 19
##     year month   day dep_time sched_de…¹ dep_d…² arr_t…³ sched…⁴ arr_d…⁵ carrier
##    <int> <int> <int>    <int>      <int>   <dbl>   <int>   <int>   <dbl> <chr>  
##  1  2013     1     1      857        900      -3    1516    1530     -14 HA     
##  2  2013     1     2      909        900       9    1525    1530      -5 HA     
##  3  2013     1     3      914        900      14    1504    1530     -26 HA     
##  4  2013     1     4      900        900       0    1516    1530     -14 HA     
##  5  2013     1     5      858        900      -2    1519    1530     -11 HA     
##  6  2013     1     6     1019        900      79    1558    1530      28 HA     
##  7  2013     1     7     1042        900     102    1620    1530      50 HA     
##  8  2013     1     8      901        900       1    1504    1530     -26 HA     
##  9  2013     1     9      641        900    1301    1242    1530    1272 HA     
## 10  2013     1    10      859        900      -1    1449    1530     -41 HA     
## # … with 336,766 more rows, 9 more variables: flight <int>, tailnum <chr>,
## #   origin <chr>, dest <chr>, air_time <dbl>, distance <dbl>, hour <dbl>,
## #   minute <dbl>, time_hour <dttm>, and abbreviated variable names
## #   ¹​sched_dep_time, ²​dep_delay, ³​arr_time, ⁴​sched_arr_time, ⁵​arr_delay
arrange(flights, distance)
## # A tibble: 336,776 x 19
##     year month   day dep_time sched_de…¹ dep_d…² arr_t…³ sched…⁴ arr_d…⁵ carrier
##    <int> <int> <int>    <int>      <int>   <dbl>   <int>   <int>   <dbl> <chr>  
##  1  2013     7    27       NA        106      NA      NA     245      NA US     
##  2  2013     1     3     2127       2129      -2    2222    2224      -2 EV     
##  3  2013     1     4     1240       1200      40    1333    1306      27 EV     
##  4  2013     1     4     1829       1615     134    1937    1721     136 EV     
##  5  2013     1     4     2128       2129      -1    2218    2224      -6 EV     
##  6  2013     1     5     1155       1200      -5    1241    1306     -25 EV     
##  7  2013     1     6     2125       2129      -4    2224    2224       0 EV     
##  8  2013     1     7     2124       2129      -5    2212    2224     -12 EV     
##  9  2013     1     8     2127       2130      -3    2304    2225      39 EV     
## 10  2013     1     9     2126       2129      -3    2217    2224      -7 EV     
## # … with 336,766 more rows, 9 more variables: flight <int>, tailnum <chr>,
## #   origin <chr>, dest <chr>, air_time <dbl>, distance <dbl>, hour <dbl>,
## #   minute <dbl>, time_hour <dttm>, and abbreviated variable names
## #   ¹​sched_dep_time, ²​dep_delay, ³​arr_time, ⁴​sched_arr_time, ⁵​arr_delay

5.4.1

  1. Brainstorm as many ways as possible to select dep_time, dep_delay, arr_time, and arr_delay from flights.
select(flights, dep_time, dep_delay, arr_time, arr_delay)
## # A tibble: 336,776 x 4
##    dep_time dep_delay arr_time arr_delay
##       <int>     <dbl>    <int>     <dbl>
##  1      517         2      830        11
##  2      533         4      850        20
##  3      542         2      923        33
##  4      544        -1     1004       -18
##  5      554        -6      812       -25
##  6      554        -4      740        12
##  7      555        -5      913        19
##  8      557        -3      709       -14
##  9      557        -3      838        -8
## 10      558        -2      753         8
## # … with 336,766 more rows
select(flights, any_of(c("dep_time", "dep_delay", "arr_time", "arr_delay")))
## # A tibble: 336,776 x 4
##    dep_time dep_delay arr_time arr_delay
##       <int>     <dbl>    <int>     <dbl>
##  1      517         2      830        11
##  2      533         4      850        20
##  3      542         2      923        33
##  4      544        -1     1004       -18
##  5      554        -6      812       -25
##  6      554        -4      740        12
##  7      555        -5      913        19
##  8      557        -3      709       -14
##  9      557        -3      838        -8
## 10      558        -2      753         8
## # … with 336,766 more rows
select(flights, starts_with("dep_"), starts_with("arr_"))
## # A tibble: 336,776 x 4
##    dep_time dep_delay arr_time arr_delay
##       <int>     <dbl>    <int>     <dbl>
##  1      517         2      830        11
##  2      533         4      850        20
##  3      542         2      923        33
##  4      544        -1     1004       -18
##  5      554        -6      812       -25
##  6      554        -4      740        12
##  7      555        -5      913        19
##  8      557        -3      709       -14
##  9      557        -3      838        -8
## 10      558        -2      753         8
## # … with 336,766 more rows
  1. What happens if you include the name of a variable multiple times in a select() call? Nothing happens and the select() function ignores the duplicate
select(flights, dep_time, dep_time)
## # A tibble: 336,776 x 1
##    dep_time
##       <int>
##  1      517
##  2      533
##  3      542
##  4      544
##  5      554
##  6      554
##  7      555
##  8      557
##  9      557
## 10      558
## # … with 336,766 more rows
  1. What does the any_of() function do? Why might it be helpful in conjunction with this vector?
vars <- c("year", "month", "day", "dep_delay", "arr_delay")
select(flights, any_of(vars)) #select all the variables in the vector
## # A tibble: 336,776 x 5
##     year month   day dep_delay arr_delay
##    <int> <int> <int>     <dbl>     <dbl>
##  1  2013     1     1         2        11
##  2  2013     1     1         4        20
##  3  2013     1     1         2        33
##  4  2013     1     1        -1       -18
##  5  2013     1     1        -6       -25
##  6  2013     1     1        -4        12
##  7  2013     1     1        -5        19
##  8  2013     1     1        -3       -14
##  9  2013     1     1        -3        -8
## 10  2013     1     1        -2         8
## # … with 336,766 more rows
  1. Does the result of running the following code surprise you? How do the select helpers deal with case by default? How can you change that default?
select(flights, contains("TIME"))
## # A tibble: 336,776 x 6
##    dep_time sched_dep_time arr_time sched_arr_time air_time time_hour          
##       <int>          <int>    <int>          <int>    <dbl> <dttm>             
##  1      517            515      830            819      227 2013-01-01 05:00:00
##  2      533            529      850            830      227 2013-01-01 05:00:00
##  3      542            540      923            850      160 2013-01-01 05:00:00
##  4      544            545     1004           1022      183 2013-01-01 05:00:00
##  5      554            600      812            837      116 2013-01-01 06:00:00
##  6      554            558      740            728      150 2013-01-01 05:00:00
##  7      555            600      913            854      158 2013-01-01 06:00:00
##  8      557            600      709            723       53 2013-01-01 06:00:00
##  9      557            600      838            846      140 2013-01-01 06:00:00
## 10      558            600      753            745      138 2013-01-01 06:00:00
## # … with 336,766 more rows
#This is not surprising to ignore uppercase character and makes it easier to search
select(flights, contains("TIME", ignore.case = FALSE))
## # A tibble: 336,776 x 0

5.5.2

  1. Currently dep_time and sched_dep_time are convenient to look at, but hard to compute with because they’re not really continuous numbers. Convert them to a more convenient representation of number of minutes since midnight.
flights %>%
  transmute(
       dep_time,
       hour1 = dep_time %/% 100,
       minute1 = dep_time %% 100,
       dep_time = hour1*60 + minute1,
       sched_dep_time,
       hour2 = sched_dep_time %/% 100,
       minute2 = sched_dep_time %% 100,
       sched_dep_time = hour2*60 + minute2)
## # A tibble: 336,776 x 6
##    dep_time hour1 minute1 sched_dep_time hour2 minute2
##       <dbl> <dbl>   <dbl>          <dbl> <dbl>   <dbl>
##  1      317     5      17            315     5      15
##  2      333     5      33            329     5      29
##  3      342     5      42            340     5      40
##  4      344     5      44            345     5      45
##  5      354     5      54            360     6       0
##  6      354     5      54            358     5      58
##  7      355     5      55            360     6       0
##  8      357     5      57            360     6       0
##  9      357     5      57            360     6       0
## 10      358     5      58            360     6       0
## # … with 336,766 more rows
  1. Compare air_time with arr_time - dep_time. What do you expect to see? What do you see? What do you need to do to fix it?
flights %>%
  transmute(
    dep_time,
    hour1 = dep_time %/% 100,
    minute1 = dep_time %% 100,
    dep_time = hour1*60 + minute1,
    arr_time,
    hour2 = arr_time %/% 100,
    minute2 = arr_time %% 100,
    arr_time = hour2*60 + minute2,
    air_time,
    diff = arr_time - dep_time)
## # A tibble: 336,776 x 8
##    dep_time hour1 minute1 arr_time hour2 minute2 air_time  diff
##       <dbl> <dbl>   <dbl>    <dbl> <dbl>   <dbl>    <dbl> <dbl>
##  1      317     5      17      510     8      30      227   193
##  2      333     5      33      530     8      50      227   197
##  3      342     5      42      563     9      23      160   221
##  4      344     5      44      604    10       4      183   260
##  5      354     5      54      492     8      12      116   138
##  6      354     5      54      460     7      40      150   106
##  7      355     5      55      553     9      13      158   198
##  8      357     5      57      429     7       9       53    72
##  9      357     5      57      518     8      38      140   161
## 10      358     5      58      473     7      53      138   115
## # … with 336,766 more rows

air_time and arr_time - dep_time is different even though they should be the same This could be a change in time zones or entering a new day

  1. Compare dep_time, sched_dep_time, and dep_delay. How would you expect those three numbers to be related?
flights %>%
  transmute(dep_delay,
         dep_time = (dep_time %/% 100 * 60 + dep_time %% 100),
         sched_dep_time = (sched_dep_time %/% 100 * 60 + sched_dep_time %% 100),
         dep_delay_diff = dep_delay - dep_time + sched_dep_time)
## # A tibble: 336,776 x 4
##    dep_delay dep_time sched_dep_time dep_delay_diff
##        <dbl>    <dbl>          <dbl>          <dbl>
##  1         2      317            315              0
##  2         4      333            329              0
##  3         2      342            340              0
##  4        -1      344            345              0
##  5        -6      354            360              0
##  6        -4      354            358              0
##  7        -5      355            360              0
##  8        -3      357            360              0
##  9        -3      357            360              0
## 10        -2      358            360              0
## # … with 336,766 more rows
#dep_delay should be equals to dep_time - schedule_dep_time; 
# which is what we see with difference being 0
  1. Find the 10 most delayed flights using a ranking function. How do you want to handle ties? Carefully read the documentation for min_rank().
arrange(flights, desc(dep_delay))
## # A tibble: 336,776 x 19
##     year month   day dep_time sched_de…¹ dep_d…² arr_t…³ sched…⁴ arr_d…⁵ carrier
##    <int> <int> <int>    <int>      <int>   <dbl>   <int>   <int>   <dbl> <chr>  
##  1  2013     1     9      641        900    1301    1242    1530    1272 HA     
##  2  2013     6    15     1432       1935    1137    1607    2120    1127 MQ     
##  3  2013     1    10     1121       1635    1126    1239    1810    1109 MQ     
##  4  2013     9    20     1139       1845    1014    1457    2210    1007 AA     
##  5  2013     7    22      845       1600    1005    1044    1815     989 MQ     
##  6  2013     4    10     1100       1900     960    1342    2211     931 DL     
##  7  2013     3    17     2321        810     911     135    1020     915 DL     
##  8  2013     6    27      959       1900     899    1236    2226     850 DL     
##  9  2013     7    22     2257        759     898     121    1026     895 DL     
## 10  2013    12     5      756       1700     896    1058    2020     878 AA     
## # … with 336,766 more rows, 9 more variables: flight <int>, tailnum <chr>,
## #   origin <chr>, dest <chr>, air_time <dbl>, distance <dbl>, hour <dbl>,
## #   minute <dbl>, time_hour <dttm>, and abbreviated variable names
## #   ¹​sched_dep_time, ²​dep_delay, ³​arr_time, ⁴​sched_arr_time, ⁵​arr_delay
flights %>%
  mutate(
    rank = min_rank(desc(dep_delay))
  )
## # A tibble: 336,776 x 20
##     year month   day dep_time sched_de…¹ dep_d…² arr_t…³ sched…⁴ arr_d…⁵ carrier
##    <int> <int> <int>    <int>      <int>   <dbl>   <int>   <int>   <dbl> <chr>  
##  1  2013     1     1      517        515       2     830     819      11 UA     
##  2  2013     1     1      533        529       4     850     830      20 UA     
##  3  2013     1     1      542        540       2     923     850      33 AA     
##  4  2013     1     1      544        545      -1    1004    1022     -18 B6     
##  5  2013     1     1      554        600      -6     812     837     -25 DL     
##  6  2013     1     1      554        558      -4     740     728      12 UA     
##  7  2013     1     1      555        600      -5     913     854      19 B6     
##  8  2013     1     1      557        600      -3     709     723     -14 EV     
##  9  2013     1     1      557        600      -3     838     846      -8 B6     
## 10  2013     1     1      558        600      -2     753     745       8 AA     
## # … with 336,766 more rows, 10 more variables: flight <int>, tailnum <chr>,
## #   origin <chr>, dest <chr>, air_time <dbl>, distance <dbl>, hour <dbl>,
## #   minute <dbl>, time_hour <dttm>, rank <int>, and abbreviated variable names
## #   ¹​sched_dep_time, ²​dep_delay, ³​arr_time, ⁴​sched_arr_time, ⁵​arr_delay
  1. What does 1:3 + 1:10 return? Why? 1:3 + 1:10 It returns a vector that contains values that were the sum of the two vectors The equation goes: 1+1, 2+2, 3+3, 1+4, 2+5, 3+6, 1+7, 2+8, 3+9, 1+10 The length is equal to the length of 1:10 (warning message)

  2. What trigonometric functions does R provide? We can find out by ?Trig There are cos(), sin(), tan(), acos(), asin(), atan(x), atan2(y, x), cospi(), sinpi(), tanpi()

5.6.7 Exercises

  1. Brainstorm at least 5 different ways to assess the typical delay characteristics of a group of flights. Consider the following scenarios: A flight is 15 minutes early 50% of the time, and 15 minutes late 50% of the time A flight is always 10 mins late A fight is 30 minutes early 50% of the time, and 30 minutes late 50% of the time. 99% of the time a flight is on time. 1% of the time it’s 2 hours late. What is more important: arrival delay or departure delay?

If thinking from passengers’ perspectives, arrival delay is more important as it affects their next plans or even the next connecting flights. This is probability. A flight might be 99% on time, but that 1% long delay can affect people more than frequent 10 minutes.

  1. Come up with another approach that will give you the same output as not_cancelled %>% count(dest)
flights %>%
  filter(!is.na(dep_delay), !is.na(arr_delay)) %>%
  group_by(dest) %>%
  summarise(count = n())
## # A tibble: 104 x 2
##    dest  count
##    <chr> <int>
##  1 ABQ     254
##  2 ACK     264
##  3 ALB     418
##  4 ANC       8
##  5 ATL   16837
##  6 AUS    2411
##  7 AVL     261
##  8 BDL     412
##  9 BGR     358
## 10 BHM     269
## # … with 94 more rows

And alternative to not_cancelled %>% count(tailnum, wt = distance) (without using count()).

flights %>%
  filter(!is.na(dep_delay), !is.na(arr_delay)) %>%
  group_by(tailnum) %>%
  summarise(count = sum(distance))
## # A tibble: 4,037 x 2
##    tailnum  count
##    <chr>    <dbl>
##  1 D942DN    3418
##  2 N0EGMQ  239143
##  3 N10156  109664
##  4 N102UW   25722
##  5 N103US   24619
##  6 N104UW   24616
##  7 N10575  139903
##  8 N105UW   23618
##  9 N107US   21677
## 10 N108UW   32070
## # … with 4,027 more rows
  1. Our definition of cancelled flights (is.na(dep_delay) | is.na(arr_delay) ) is slightly suboptimal. Why? Which is the most important column?

The flights can be redirected or landed at another airport, which might not show up in arr_delay or dep_delay We can look at the actual airtime of the flight (air_time)

  1. Look at the number of cancelled flights per day.
flights %>%
  mutate(cancel = is.na(arr_time)) %>%
  group_by(year, month, day) %>%
  summarise(count = n(),
            cancelled = sum(cancel)
            ) %>%
  ggplot() +
  geom_point(aes(x = count, y = cancelled))
## `summarise()` has grouped output by 'year', 'month'. You can override using the
## `.groups` argument.

#More delays seems to be correlated with more flights

#Is there a pattern? Is the proportion of cancelled flights related to the average delay?
flights %>%
  mutate(cancel = is.na(arr_time)) %>%
  group_by(year, month, day) %>%
  summarise(delay = mean(arr_delay, na.rm = TRUE),
            cancelled = sum(cancel)
  ) %>%
  ggplot() +
  geom_point(aes(x = delay, y = cancelled))
## `summarise()` has grouped output by 'year', 'month'. You can override using the
## `.groups` argument.

#similarly, there are likely more cancelled flights with higher delay rates
  1. Which carrier has the worst delays?
flights%>%
  group_by(carrier) %>%
  summarise(delay = mean(arr_delay, na.rm = TRUE)) %>%
  arrange(desc(delay))
## # A tibble: 16 x 2
##    carrier  delay
##    <chr>    <dbl>
##  1 F9      21.9  
##  2 FL      20.1  
##  3 EV      15.8  
##  4 YV      15.6  
##  5 OO      11.9  
##  6 MQ      10.8  
##  7 WN       9.65 
##  8 B6       9.46 
##  9 9E       7.38 
## 10 UA       3.56 
## 11 US       2.13 
## 12 VX       1.76 
## 13 DL       1.64 
## 14 AA       0.364
## 15 HA      -6.92 
## 16 AS      -9.93
#F9 has the worst delay

Challenge: can you disentangle the effects of bad airports vs. bad carriers? Why/why not? (Hint: think about flights %>% group_by(carrier, dest) %>% summarise(n()))

flights %>%
  group_by(carrier, dest) %>%
  summarise(delay = mean(arr_delay, na.rm = TRUE),
            count = n()) %>%
  arrange(desc(delay))
## `summarise()` has grouped output by 'carrier'. You can override using the
## `.groups` argument.
## # A tibble: 314 x 4
## # Groups:   carrier [16]
##    carrier dest  delay count
##    <chr>   <chr> <dbl> <int>
##  1 UA      STL   110       2
##  2 OO      ORD   107       1
##  3 OO      DTW    68.5     2
##  4 UA      RDU    56       1
##  5 EV      CAE    42.8   113
##  6 EV      TYS    41.2   323
##  7 EV      PBI    40.7     6
##  8 EV      TUL    33.7   315
##  9 EV      OKC    30.6   346
## 10 UA      JAC    29.9    23
## # … with 304 more rows
  1. What does the sort argument to count() do. When might you use it?

The count() argument sort data in the order of observations(n)

5.7.1 Exercises

  1. Refer back to the lists of useful mutate and filtering functions. Describe how each operation changes when you combine it with grouping.

The mutate and filtering functions would be apply to an entire variable/ column after grouping, they will be applied to the groups we set.

  1. Which plane (tailnum) has the worst on-time record?
flights %>%
  group_by(tailnum) %>%
  filter(!is.na(arr_delay)) %>%
  summarise(delay = mean(arr_delay)) %>%
  arrange(desc(delay))
## # A tibble: 4,037 x 2
##    tailnum delay
##    <chr>   <dbl>
##  1 N844MH   320 
##  2 N911DA   294 
##  3 N922EV   276 
##  4 N587NW   264 
##  5 N851NW   219 
##  6 N928DN   201 
##  7 N7715E   188 
##  8 N654UA   185 
##  9 N665MQ   175.
## 10 N427SW   157 
## # … with 4,027 more rows
#N844MH has the worst record
  1. What time of day should you fly if you want to avoid delays as much as possible?
flights %>%
  group_by(hour) %>%
  filter(!is.na(dep_delay)) %>%
  summarise(delay = mean(dep_delay))
## # A tibble: 19 x 2
##     hour  delay
##    <dbl>  <dbl>
##  1     5  0.688
##  2     6  1.64 
##  3     7  1.91 
##  4     8  4.13 
##  5     9  4.58 
##  6    10  6.50 
##  7    11  7.19 
##  8    12  8.61 
##  9    13 11.4  
## 10    14 13.8  
## 11    15 16.9  
## 12    16 18.8  
## 13    17 21.1  
## 14    18 21.1  
## 15    19 24.8  
## 16    20 24.3  
## 17    21 24.2  
## 18    22 18.8  
## 19    23 14.0
#They should leave early in the morning (5-9 a.m.)
  1. For each destination, compute the total minutes of delay.
flights %>%
  group_by(dest) %>%
  filter(!is.na(dep_delay)) %>%
  summarise(delay = sum(dep_delay))
## # A tibble: 104 x 2
##    dest   delay
##    <chr>  <dbl>
##  1 ABQ     3490
##  2 ACK     1711
##  3 ALB     9897
##  4 ANC      103
##  5 ATL   211391
##  6 AUS    31496
##  7 AVL     2154
##  8 BDL     7301
##  9 BGR     7011
## 10 BHM     8077
## # … with 94 more rows
#For each flight, compute the proportion of the total delay for its destination.
flights %>%
  group_by(dest) %>%
  filter(!is.na(dep_delay)) %>%
  summarise(delay = sum(dep_delay),
            prop = dep_delay/ delay)
## `summarise()` has grouped output by 'dest'. You can override using the `.groups`
## argument.
## # A tibble: 328,521 x 3
## # Groups:   dest [104]
##    dest  delay      prop
##    <chr> <dbl>     <dbl>
##  1 ABQ    3490 -0.00172 
##  2 ABQ    3490  0.00258 
##  3 ABQ    3490 -0.00172 
##  4 ABQ    3490  0.00458 
##  5 ABQ    3490  0       
##  6 ABQ    3490 -0.000573
##  7 ABQ    3490  0.000287
##  8 ABQ    3490 -0.00115 
##  9 ABQ    3490 -0.00115 
## 10 ABQ    3490  0.00287 
## # … with 328,511 more rows
  1. Delays are typically temporally correlated: even once the problem that caused the initial delay has been resolved, later flights are delayed to allow earlier flights to leave. Using lag(), explore how the delay of a flight is related to the delay of the immediately preceding flight.
flights %>%
  group_by(origin) %>%
  filter(!is.na(dep_delay)) %>%
  mutate(lag = lag(dep_delay, default = 0)) %>%
  ggplot() +
  geom_point(aes(x = dep_delay, y = lag))

# the delay of the immediate preceding flight is positively correlated with the delay of the next flight
  1. Look at each destination. Can you find flights that are suspiciously fast? (i.e. flights that represent a potential data entry error).
flights %>% 
  filter(!is.na(air_time)) %>%
  select(dest, air_time, carrier, flight, tailnum, distance) %>%
  group_by(dest) %>%
  mutate(speed = distance/ air_time) %>%
  arrange(speed)
## # A tibble: 327,346 x 7
## # Groups:   dest [104]
##    dest  air_time carrier flight tailnum distance speed
##    <chr>    <dbl> <chr>    <int> <chr>      <dbl> <dbl>
##  1 PHL         75 US        1860 N755US        96  1.28
##  2 ACK        141 B6        1491 N328JB       199  1.41
##  3 PHL         61 9E        3608 N8932C        94  1.54
##  4 PHL         59 9E        3667 N832AY        94  1.59
##  5 PHL         60 US        1909 N951UW        96  1.6 
##  6 PHL         60 US        1289 N956UW        96  1.6 
##  7 PHL         59 US        1775 N945UW        96  1.63
##  8 DCA        131 US        2175 N745VJ       214  1.63
##  9 PHL         57 US        1279 N953UW        96  1.68
## 10 PHL         55 9E        3638 N8631E        94  1.71
## # … with 327,336 more rows

Compute the air time of a flight relative to the shortest flight to that destination. Which flights were most delayed in the air?

flights %>% 
  filter(!is.na(air_time)) %>%
  select(dest, air_time, carrier, flight, tailnum, distance) %>%
  group_by(dest) %>%
  mutate(speed = distance/ air_time) %>%
  arrange(desc(speed))
## # A tibble: 327,346 x 7
## # Groups:   dest [104]
##    dest  air_time carrier flight tailnum distance speed
##    <chr>    <dbl> <chr>    <int> <chr>      <dbl> <dbl>
##  1 ATL         65 DL        1499 N666DN       762 11.7 
##  2 MSP         93 EV        4667 N17196      1008 10.8 
##  3 GSP         55 EV        4292 N14568       594 10.8 
##  4 BNA         70 EV        3805 N12567       748 10.7 
##  5 PBI        105 DL        1902 N956DL      1035  9.86
##  6 SJU        170 DL         315 N3768       1598  9.4 
##  7 SJU        172 B6         707 N779JB      1598  9.29
##  8 STT        175 AA         936 N5FFAA      1623  9.27
##  9 SJU        173 DL         347 N3773D      1598  9.24
## 10 SJU        173 B6        1503 N571JB      1598  9.24
## # … with 327,336 more rows
  1. Find all destinations that are flown by at least two carriers.
flights %>%
  filter(!is.na(air_time)) %>%
  group_by(dest) %>%
  summarise(count = n_distinct(carrier, na.rm = TRUE)) %>%
  filter(count > 1)
## # A tibble: 75 x 2
##    dest  count
##    <chr> <int>
##  1 ATL       7
##  2 AUS       6
##  3 AVL       2
##  4 BDL       2
##  5 BNA       5
##  6 BOS       7
##  7 BQN       2
##  8 BTV       3
##  9 BUF       4
## 10 BWI       4
## # … with 65 more rows
#Use that information to rank the carriers.
flights %>%
  filter(!is.na(air_time)) %>%
  group_by(carrier) %>%
  summarise(count = n_distinct(dest, na.rm = TRUE)) %>%
  filter(count > 1) %>%
  arrange(desc(count))
## # A tibble: 13 x 2
##    carrier count
##    <chr>   <int>
##  1 EV         61
##  2 9E         48
##  3 UA         47
##  4 B6         42
##  5 DL         40
##  6 MQ         20
##  7 AA         19
##  8 WN         11
##  9 OO          5
## 10 US          5
## 11 VX          5
## 12 FL          3
## 13 YV          3
  1. For each plane, count the number of flights before the first delay of greater than 1 hour.
flights %>%
  filter(!is.na(air_time)) %>%
  select(tailnum, dep_delay, year, month, day) %>%
  arrange(year, month, day) %>% 
  group_by(tailnum) %>%
  mutate(delay = cumsum(dep_delay >60)) %>%
  summarise(count = sum(delay))
## # A tibble: 4,037 x 2
##    tailnum count
##    <chr>   <int>
##  1 D942DN      4
##  2 N0EGMQ   4358
##  3 N10156   1668
##  4 N102UW     32
##  5 N103US      0
##  6 N104UW    106
##  7 N10575   6524
##  8 N105UW     23
##  9 N107US     21
## 10 N108UW     26
## # … with 4,027 more rows

Chapter 6

6.3 Exercises

  1. Go to the RStudio Tips twitter account, https://twitter.com/rstudiotips and find one tip that looks interesting. Practice using it!

You can access R Cheatsheets straight from RStudio, by doing the following: Help in Menu Bar > Cheat Sheets > Browse Cheat Sheets…

Bonus tip: You select a number in RStudio, you can hit Option+Shift ↑ or Option+Shift ↓ to increment/decrement the number. We tried it in the Console. Cool!

  1. What other common mistakes will RStudio diagnostics report? Read https://support.rstudio.com/hc/en-us/articles/205753617-Code-Diagnostics to find out.

Some common mistakes the diagnostics report will reveal are: - Missing arguments, unmatched arguments, partially matched arguments, and too many arguments - If variable used has no definition in scope or if variable is defined but not used - Inappropriate use (or lack thereof) of whitespace

Bulut & Dejardins (2019)

Chapter 4

library(data.table)
## Warning: package 'data.table' was built under R version 4.0.2
## 
## Attaching package: 'data.table'
## The following objects are masked from 'package:dplyr':
## 
##     between, first, last
## The following object is masked from 'package:purrr':
## 
##     transpose

data.table(DT) has a general form DT[i, j, by] where i = on which row; j = what to do; and by = grouped by what

4.2.1 Exercises

Import Data Set The pisa data set is too large so I will use the region6 data instead

pisa <- fread("~/Desktop/Academics/2022 Fall/Applied Data Science/Data Sets/region6.csv", na.strings = "")
class(pisa)
## [1] "data.table" "data.frame"
print(object.size(pisa), unit = "GB")
## 1.1 Gb

4.3.1 Exercises

  1. Subset all the Female students (ST004D01T) in Germany
pisa[CNTRYID == "Germany" & ST004D01T == "Female"]
##       CNTRYID     CNT CNTSCHID CNTSTUID  CYC  NatCen  Region
##    1: Germany Germany 27600001 27605365 06MS Germany Germany
##    2: Germany Germany 27600001 27601858 06MS Germany Germany
##    3: Germany Germany 27600001 27602008 06MS Germany Germany
##    4: Germany Germany 27600001 27606950 06MS Germany Germany
##    5: Germany Germany 27600001 27611010 06MS Germany Germany
##   ---                                                       
## 3193: Germany Germany 27600262 27601530 06MS Germany Germany
## 3194: Germany Germany 27600262 27606088 06MS Germany Germany
## 3195: Germany Germany 27600262 27606696 06MS Germany Germany
## 3196: Germany Germany 27600262 27606135 06MS Germany Germany
## 3197: Germany Germany 27600262 27611733 06MS Germany Germany
##                             STRATUM SUBNATIO OECD ADMINMODE Option_CPS
##    1: Undisclosed STRATUM - Germany  Germany  Yes  Computer        Yes
##    2: Undisclosed STRATUM - Germany  Germany  Yes  Computer        Yes
##    3: Undisclosed STRATUM - Germany  Germany  Yes  Computer        Yes
##    4: Undisclosed STRATUM - Germany  Germany  Yes  Computer        Yes
##    5: Undisclosed STRATUM - Germany  Germany  Yes  Computer        Yes
##   ---                                                                 
## 3193: Undisclosed STRATUM - Germany  Germany  Yes  Computer        Yes
## 3194: Undisclosed STRATUM - Germany  Germany  Yes  Computer        Yes
## 3195: Undisclosed STRATUM - Germany  Germany  Yes  Computer        Yes
## 3196: Undisclosed STRATUM - Germany  Germany  Yes  Computer        Yes
## 3197: Undisclosed STRATUM - Germany  Germany  Yes  Computer        Yes
##       Option_FL Option_ICTQ Option_ECQ Option_PQ Option_TQ Option_UH
##    1:        No         Yes        Yes       Yes       Yes       Yes
##    2:        No         Yes        Yes       Yes       Yes       Yes
##    3:        No         Yes        Yes       Yes       Yes       Yes
##    4:        No         Yes        Yes       Yes       Yes       Yes
##    5:        No         Yes        Yes       Yes       Yes       Yes
##   ---                                                               
## 3193:        No         Yes        Yes       Yes       Yes       Yes
## 3194:        No         Yes        Yes       Yes       Yes       Yes
## 3195:        No         Yes        Yes       Yes       Yes       Yes
## 3196:        No         Yes        Yes       Yes       Yes       Yes
## 3197:        No         Yes        Yes       Yes       Yes       Yes
##            Option_Read      Option_Math LANGTEST_QQQ LANGTEST_COG LANGTEST_PAQ
##    1: Standard Cluster Standard Cluster       German       German         <NA>
##    2: Standard Cluster Standard Cluster       German       German       German
##    3: Standard Cluster Standard Cluster       German       German       German
##    4: Standard Cluster Standard Cluster       German       German         <NA>
##    5: Standard Cluster Standard Cluster       German       German       German
##   ---                                                                         
## 3193: Standard Cluster Standard Cluster       German       German       German
## 3194: Standard Cluster Standard Cluster       German       German       German
## 3195: Standard Cluster Standard Cluster       German       German       German
## 3196: Standard Cluster Standard Cluster       German       German       German
## 3197: Standard Cluster Standard Cluster       German       German         <NA>
##                        CBASCI        BOOKID ST001D01T ST003D02T ST003D03T
##    1: Science Random Number 1 Form 32 (CBA)   Grade 9   January      1999
##    2: Science Random Number 3 Form 44 (CBA)   Grade 9   October      1999
##    3: Science Random Number 4 Form 95 (CBA)   Grade 9  November      1999
##    4: Science Random Number 4 Form 96 (CBA)  Grade 10      June      1999
##    5: Science Random Number 5 Form 46 (CBA)  Grade 10     March      1999
##   ---                                                                    
## 3193: Science Random Number 1 Form 43 (CBA)  Grade 10     March      1999
## 3194: Science Random Number 2 Form 32 (CBA)  Grade 10       May      1999
## 3195: Science Random Number 4 Form 44 (CBA)  Grade 10      June      1999
## 3196: Science Random Number 5 Form 93 (CBA)  Grade 10     March      1999
## 3197: Science Random Number 1 Form 90 (CBA)  Grade 10  February      1999
##       ST004D01T       ST005Q01TA ST006Q01TA ST006Q02TA ST006Q03TA ST006Q04TA
##    1:    Female             <NA>       <NA>       <NA>       <NA>       <NA>
##    2:    Female  <ISCED level 2>         No         No         No        Yes
##    3:    Female  <ISCED level 2>         No        Yes         No         No
##    4:    Female <ISCED level 3A>         No        Yes         No         No
##    5:    Female  <ISCED level 2>       <NA>       <NA>       <NA>        Yes
##   ---                                                                       
## 3193:    Female  <ISCED level 2>         No         No         No         No
## 3194:    Female  <ISCED level 2>         No         No         No         No
## 3195:    Female  <ISCED level 2>         No         No         No         No
## 3196:    Female  <ISCED level 2>         No         No        Yes         No
## 3197:    Female <ISCED level 3A>       <NA>       <NA>       <NA>        Yes
##                 ST007Q01TA ST008Q01TA ST008Q02TA ST008Q03TA ST008Q04TA
##    1:     <ISCED level 3A>       <NA>       <NA>        Yes       <NA>
##    2:      <ISCED level 2>         No         No         No         No
##    3:      <ISCED level 2>         No         No         No         No
##    4:     <ISCED level 3A>        Yes        Yes         No         No
##    5:      <ISCED level 2>       <NA>       <NA>       <NA>       <NA>
##   ---                                                                 
## 3193:      <ISCED level 2>         No         No         No         No
## 3194: <ISCED level 3B, 3C>         No         No         No         No
## 3195:      <ISCED level 2>         No         No         No       <NA>
## 3196:     <ISCED level 3A>         No         No        Yes         No
## 3197:      <ISCED level 2>       <NA>        Yes       <NA>       <NA>
##       ST011Q01TA ST011Q02TA ST011Q03TA ST011Q04TA ST011Q05TA ST011Q06TA
##    1:        Yes        Yes        Yes        Yes        Yes        Yes
##    2:        Yes        Yes        Yes        Yes        Yes        Yes
##    3:        Yes        Yes        Yes        Yes         No        Yes
##    4:        Yes        Yes        Yes        Yes        Yes        Yes
##    5:        Yes        Yes        Yes        Yes        Yes        Yes
##   ---                                                                  
## 3193:        Yes        Yes        Yes        Yes        Yes        Yes
## 3194:        Yes        Yes        Yes        Yes         No        Yes
## 3195:         No        Yes        Yes         No         No        Yes
## 3196:        Yes        Yes        Yes        Yes        Yes        Yes
## 3197:        Yes        Yes        Yes        Yes         No        Yes
##       ST011Q07TA ST011Q08TA ST011Q09TA ST011Q10TA ST011Q11TA ST011Q12TA
##    1:        Yes        Yes        Yes        Yes        Yes        Yes
##    2:         No         No         No        Yes        Yes        Yes
##    3:         No         No         No        Yes         No        Yes
##    4:        Yes        Yes        Yes        Yes        Yes        Yes
##    5:         No        Yes         No        Yes        Yes        Yes
##   ---                                                                  
## 3193:        Yes        Yes        Yes        Yes        Yes        Yes
## 3194:         No         No        Yes        Yes        Yes        Yes
## 3195:         No         No         No        Yes         No        Yes
## 3196:        Yes        Yes        Yes        Yes        Yes        Yes
## 3197:         No        Yes        Yes        Yes        Yes        Yes
##       ST011Q16NA
##    1:        Yes
##    2:        Yes
##    3:         No
##    4:        Yes
##    5:        Yes
##   ---           
## 3193:         No
## 3194:        Yes
## 3195:         No
## 3196:         No
## 3197:        Yes
##                                                                         ST011D17TA
##    1: Germany : A game console (z. B. Playstation®, Nintendo®, X-Box®, Wii®) - Yes
##    2: Germany : A game console (z. B. Playstation®, Nintendo®, X-Box®, Wii®) - Yes
##    3: Germany : A game console (z. B. Playstation®, Nintendo®, X-Box®, Wii®) - Yes
##    4:  Germany : A game console (z. B. Playstation®, Nintendo®, X-Box®, Wii®) - No
##    5: Germany : A game console (z. B. Playstation®, Nintendo®, X-Box®, Wii®) - Yes
##   ---                                                                             
## 3193: Germany : A game console (z. B. Playstation®, Nintendo®, X-Box®, Wii®) - Yes
## 3194: Germany : A game console (z. B. Playstation®, Nintendo®, X-Box®, Wii®) - Yes
## 3195: Germany : A game console (z. B. Playstation®, Nintendo®, X-Box®, Wii®) - Yes
## 3196: Germany : A game console (z. B. Playstation®, Nintendo®, X-Box®, Wii®) - Yes
## 3197: Germany : A game console (z. B. Playstation®, Nintendo®, X-Box®, Wii®) - Yes
##                              ST011D18TA                 ST011D19TA
##    1: Germany : A TV in your room - Yes Germany : Audiobooks - Yes
##    2: Germany : A TV in your room - Yes  Germany : Audiobooks - No
##    3: Germany : A TV in your room - Yes Germany : Audiobooks - Yes
##    4: Germany : A TV in your room - Yes  Germany : Audiobooks - No
##    5:  Germany : A TV in your room - No Germany : Audiobooks - Yes
##   ---                                                             
## 3193: Germany : A TV in your room - Yes Germany : Audiobooks - Yes
## 3194: Germany : A TV in your room - Yes Germany : Audiobooks - Yes
## 3195: Germany : A TV in your room - Yes  Germany : Audiobooks - No
## 3196: Germany : A TV in your room - Yes Germany : Audiobooks - Yes
## 3197: Germany : A TV in your room - Yes Germany : Audiobooks - Yes
##          ST012Q01TA    ST012Q02TA    ST012Q03TA    ST012Q05NA    ST012Q06NA
##    1: Three or more           Two           Two Three or more Three or more
##    2: Three or more           Two           One Three or more           Two
##    3: Three or more           Two Three or more Three or more Three or more
##    4: Three or more           Two           Two Three or more Three or more
##    5:           Two           One           Two Three or more           One
##   ---                                                                      
## 3193:           Two           One           Two Three or more           Two
## 3194: Three or more Three or more           One Three or more Three or more
## 3195: Three or more           One           Two Three or more Three or more
## 3196: Three or more           Two           One Three or more Three or more
## 3197: Three or more Three or more           Two Three or more Three or more
##       ST012Q07NA ST012Q08NA    ST012Q09NA          ST013Q01TA     ST123Q01NA
##    1:        Two       None Three or more       201-500 books       Disagree
##    2:       None       None          None         11-25 books Strongly agree
##    3:        Two       None Three or more       101-200 books Strongly agree
##    4:        One        One           Two       201-500 books          Agree
##    5:       None       None           One        26-100 books          Agree
##   ---                                                                       
## 3193:       None       None           Two       101-200 books Strongly agree
## 3194:        Two        One           One        26-100 books Strongly agree
## 3195:       None        One          None       101-200 books Strongly agree
## 3196:        One       None           One       201-500 books Strongly agree
## 3197:       None       None Three or more More than 500 books Strongly agree
##           ST123Q02NA        ST123Q03NA        ST123Q04NA      ST019AQ01T
##    1:          Agree             Agree          Disagree Country of test
##    2: Strongly agree    Strongly agree    Strongly agree Country of test
##    3: Strongly agree    Strongly agree    Strongly agree Country of test
##    4: Strongly agree             Agree             Agree Country of test
##    5:          Agree    Strongly agree    Strongly agree Country of test
##   ---                                                                   
## 3193: Strongly agree    Strongly agree    Strongly agree Country of test
## 3194: Strongly agree    Strongly agree    Strongly agree Country of test
## 3195:       Disagree Strongly disagree Strongly disagree Country of test
## 3196: Strongly agree    Strongly agree    Strongly agree Country of test
## 3197: Strongly agree    Strongly agree    Strongly agree Country of test
##            ST019BQ01T      ST019CQ01T ST021Q01TA       ST022Q01TA ST124Q01TA
##    1:   Other country Country of test       <NA> Language of test       <NA>
##    2: Country of test Country of test       <NA> Language of test       <NA>
##    3: Country of test Country of test       <NA> Language of test       <NA>
##    4: Country of test Country of test       <NA> Language of test       <NA>
##    5: Country of test Country of test       <NA> Language of test       <NA>
##   ---                                                                       
## 3193: Country of test Country of test       <NA> Language of test       <NA>
## 3194: Country of test   Other country       <NA> Language of test       <NA>
## 3195: Country of test Country of test       <NA> Language of test       <NA>
## 3196: Country of test   Other country       <NA> Language of test       <NA>
## 3197:   Other country Country of test       <NA> Language of test       <NA>
##       ST125Q01NA ST126Q01TA ST127Q01TA ST127Q02TA ST127Q03TA       ST111Q01TA
##    1:    3 years          6       <NA>  Yes, once       <NA> <ISCED level 3A>
##    2:    3 years          6  No, never  No, never       <NA> <ISCED level 3A>
##    3:    3 years          6  No, never  No, never       <NA> <ISCED level 3A>
##    4:    3 years          6  No, never  No, never       <NA> <ISCED level 3A>
##    5:    3 years          6  No, never  No, never       <NA> <ISCED level 3A>
##   ---                                                                        
## 3193:    4 years          6  No, never  No, never       <NA> <ISCED level 3A>
## 3194:    3 years          6  No, never  No, never       <NA>  <ISCED level 2>
## 3195:    3 years          7  No, never  No, never       <NA> <ISCED level 3A>
## 3196:    3 years          6  No, never  No, never       <NA>  <ISCED level 2>
## 3197:    4 years          6  No, never  No, never       <NA>  <ISCED level 2>
##           ST118Q01NA     ST118Q02NA     ST118Q03NA        ST118Q04NA
##    1:          Agree          Agree       Disagree          Disagree
##    2:          Agree          Agree       Disagree Strongly disagree
##    3:       Disagree       Disagree          Agree          Disagree
##    4:          Agree       Disagree          Agree          Disagree
##    5:       Disagree       Disagree       Disagree             Agree
##   ---                                                               
## 3193:          Agree          Agree          Agree          Disagree
## 3194:          Agree          Agree       Disagree          Disagree
## 3195: Strongly agree Strongly agree       Disagree          Disagree
## 3196:          Agree          Agree Strongly agree    Strongly agree
## 3197: Strongly agree Strongly agree          Agree          Disagree
##              ST118Q05NA        ST119Q01NA     ST119Q02NA        ST119Q03NA
##    1:             Agree Strongly disagree       Disagree Strongly disagree
##    2: Strongly disagree          Disagree          Agree          Disagree
##    3:          Disagree    Strongly agree Strongly agree             Agree
##    4: Strongly disagree             Agree Strongly agree          Disagree
##    5:             Agree             Agree          Agree          Disagree
##   ---                                                                     
## 3193:             Agree    Strongly agree Strongly agree             Agree
## 3194:          Disagree             Agree          Agree          Disagree
## 3195:             Agree             Agree          Agree Strongly disagree
## 3196:    Strongly agree          Disagree       Disagree          Disagree
## 3197:             Agree             Agree       Disagree             Agree
##              ST119Q04NA        ST119Q05NA        ST121Q01NA     ST121Q02NA
##    1: Strongly disagree Strongly disagree Strongly disagree          Agree
##    2:             Agree          Disagree Strongly disagree          Agree
##    3:             Agree             Agree Strongly disagree          Agree
##    4:             Agree             Agree Strongly disagree Strongly agree
##    5:             Agree             Agree Strongly disagree Strongly agree
##   ---                                                                     
## 3193:          Disagree    Strongly agree Strongly disagree Strongly agree
## 3194:          Disagree          Disagree Strongly disagree Strongly agree
## 3195:          Disagree Strongly disagree Strongly disagree          Agree
## 3196:          Disagree Strongly disagree Strongly disagree          Agree
## 3197:    Strongly agree             Agree          Disagree          Agree
##           ST121Q03NA        ST082Q01NA     ST082Q02NA     ST082Q03NA
##    1: Strongly agree             Agree          Agree          Agree
##    2: Strongly agree             Agree Strongly agree          Agree
##    3: Strongly agree             Agree Strongly agree Strongly agree
##    4: Strongly agree    Strongly agree          Agree          Agree
##    5: Strongly agree             Agree Strongly agree          Agree
##   ---                                                               
## 3193: Strongly agree             Agree Strongly agree          Agree
## 3194: Strongly agree    Strongly agree Strongly agree Strongly agree
## 3195: Strongly agree          Disagree          Agree       Disagree
## 3196: Strongly agree Strongly disagree          Agree          Agree
## 3197: Strongly agree             Agree Strongly agree          Agree
##           ST082Q08NA        ST082Q09NA     ST082Q12NA        ST082Q13NA
##    1:          Agree          Disagree          Agree             Agree
##    2: Strongly agree    Strongly agree          Agree             Agree
##    3: Strongly agree             Agree Strongly agree          Disagree
##    4:          Agree          Disagree          Agree          Disagree
##    5:          Agree          Disagree       Disagree          Disagree
##   ---                                                                  
## 3193:          Agree             Agree          Agree          Disagree
## 3194: Strongly agree    Strongly agree Strongly agree    Strongly agree
## 3195:          Agree Strongly disagree       Disagree          Disagree
## 3196:       Disagree          Disagree Strongly agree Strongly disagree
## 3197: Strongly agree          Disagree          Agree          Disagree
##           ST082Q14NA        ST034Q01TA     ST034Q02TA        ST034Q03TA
##    1: Strongly agree Strongly disagree       Disagree             Agree
##    2:          Agree Strongly disagree          Agree             Agree
##    3: Strongly agree Strongly disagree Strongly agree    Strongly agree
##    4: Strongly agree Strongly disagree Strongly agree    Strongly agree
##    5:          Agree          Disagree          Agree          Disagree
##   ---                                                                  
## 3193:          Agree Strongly disagree          Agree             Agree
## 3194: Strongly agree Strongly disagree Strongly agree    Strongly agree
## 3195:          Agree Strongly disagree          Agree          Disagree
## 3196:          Agree          Disagree          Agree             Agree
## 3197:          Agree             Agree       Disagree Strongly disagree
##              ST034Q04TA     ST034Q05TA        ST034Q06TA            ST039Q01NA
##    1: Strongly disagree          Agree          Disagree    A few times a year
##    2: Strongly disagree          Agree Strongly disagree   A few times a month
##    3: Strongly disagree          Agree Strongly disagree Never or almost never
##    4: Strongly disagree          Agree Strongly disagree   A few times a month
##    5:             Agree       Disagree             Agree   Once a week or more
##   ---                                                                         
## 3193: Strongly disagree          Agree Strongly disagree   A few times a month
## 3194: Strongly disagree Strongly agree Strongly disagree    A few times a year
## 3195:    Strongly agree          Agree          Disagree Never or almost never
## 3196: Strongly disagree          Agree Strongly disagree    A few times a year
## 3197:    Strongly agree          Agree          Disagree   Once a week or more
##                  ST039Q02NA            ST039Q03NA            ST039Q04NA
##    1:    A few times a year    A few times a year Never or almost never
##    2: Never or almost never Never or almost never Never or almost never
##    3: Never or almost never Never or almost never Never or almost never
##    4: Never or almost never Never or almost never Never or almost never
##    5:    A few times a year    A few times a year Never or almost never
##   ---                                                                  
## 3193: Never or almost never Never or almost never Never or almost never
## 3194: Never or almost never Never or almost never Never or almost never
## 3195:   A few times a month   Once a week or more   Once a week or more
## 3196:   A few times a month   Once a week or more    A few times a year
## 3197:   A few times a month   Once a week or more    A few times a year
##                  ST039Q05NA            ST039Q06NA ST059Q01TA ST059Q02TA
##    1: Never or almost never Never or almost never          4          4
##    2: Never or almost never Never or almost never          4          4
##    3: Never or almost never Never or almost never          4          4
##    4: Never or almost never Never or almost never          4          4
##    5:    A few times a year Never or almost never          4          4
##   ---                                                                  
## 3193: Never or almost never Never or almost never          4          4
## 3194: Never or almost never Never or almost never          4          4
## 3195: Never or almost never Never or almost never          4          4
## 3196: Never or almost never    A few times a year          4          4
## 3197:    A few times a year Never or almost never          4          4
##       ST059Q03TA ST060Q01NA ST061Q01NA ST062Q01TA       ST062Q02TA
##    1:          9         30         45       None             None
##    2:          6         36         45       None             None
##    3:          6         36         90       None             None
##    4:          0         33         45       None             None
##    5:          6         36         45       None             None
##   ---                                                             
## 3193:          6         30         90       None             None
## 3194:          6         32         45       None             None
## 3195:          6         32         45       None One or two times
## 3196:          2         60         45       None             None
## 3197:          4         45         45       None             None
##             ST062Q03TA ST071Q01NA ST071Q02NA ST071Q03NA ST071Q04NA ST071Q05NA
##    1:             None          1          2         NA          2          1
##    2:             None          4          6          1          1         NA
##    3:             None          1          1          1          5          1
##    4:             None         NA          1          1          2          1
##    5:             None          0          0          0          4          1
##   ---                                                                        
## 3193:             None          3          2          2          5         NA
## 3194:             None          6          4          2          1          3
## 3195:             None          0          1          0          0          1
## 3196: One or two times         NA          4          2         NA          1
## 3197:             None         NA          8          3          4          3
##       ST031Q01NA ST032Q01NA ST032Q02NA ST063Q01NA  ST063Q01NB ST063Q02NA
##    1:      1 day     3 days      1 day    Checked Not checked    Checked
##    2:      1 day     2 days     2 days    Checked     Checked    Checked
##    3:      1 day     7 days     4 days    Checked     Checked    Checked
##    4:     2 days     2 days     5 days    Checked Not checked    Checked
##    5:     2 days     7 days     4 days    Checked Not checked    Checked
##   ---                                                                   
## 3193:     3 days     6 days     5 days    Checked     Checked    Checked
## 3194:      1 day     7 days     4 days    Checked Not checked    Checked
## 3195:      1 day     4 days     3 days    Checked Not checked    Checked
## 3196:      1 day     7 days     3 days    Checked Not checked    Checked
## 3197:      1 day     4 days     4 days    Checked     Checked    Checked
##        ST063Q02NB ST063Q03NA  ST063Q03NB  ST063Q04NA  ST063Q04NB  ST063Q05NA
##    1: Not checked    Checked Not checked     Checked Not checked Not checked
##    2:     Checked    Checked     Checked Not checked Not checked Not checked
##    3:     Checked    Checked     Checked     Checked     Checked Not checked
##    4: Not checked    Checked Not checked Not checked Not checked Not checked
##    5: Not checked    Checked Not checked Not checked Not checked Not checked
##   ---                                                                       
## 3193:     Checked    Checked     Checked Not checked Not checked Not checked
## 3194: Not checked    Checked Not checked Not checked Not checked Not checked
## 3195: Not checked    Checked Not checked Not checked Not checked Not checked
## 3196: Not checked    Checked Not checked Not checked Not checked Not checked
## 3197:     Checked    Checked     Checked Not checked Not checked Not checked
##        ST063Q05NB  ST063Q06NA  ST063Q06NB               ST064Q01NA
##    1: Not checked Not checked Not checked Yes, to a certain degree
##    2: Not checked Not checked Not checked Yes, to a certain degree
##    3: Not checked Not checked Not checked Yes, to a certain degree
##    4: Not checked Not checked Not checked Yes, to a certain degree
##    5: Not checked Not checked Not checked Yes, to a certain degree
##   ---                                                             
## 3193: Not checked Not checked Not checked           No, not at all
## 3194:     Checked Not checked     Checked           No, not at all
## 3195: Not checked Not checked Not checked           No, not at all
## 3196: Not checked Not checked Not checked Yes, to a certain degree
## 3197: Not checked Not checked Not checked           No, not at all
##           ST064Q02NA               ST064Q03NA   ST097Q01TA           ST097Q02TA
##    1: No, not at all           No, not at all Some lessons         Some lessons
##    2: No, not at all           No, not at all Some lessons         Some lessons
##    3: No, not at all           No, not at all Some lessons Never or hardly ever
##    4: No, not at all Yes, to a certain degree Some lessons         Some lessons
##    5: No, not at all           No, not at all Most lessons Never or hardly ever
##   ---                                                                          
## 3193: No, not at all           No, not at all Some lessons Never or hardly ever
## 3194: No, not at all           No, not at all Some lessons Never or hardly ever
## 3195: No, not at all           No, not at all Some lessons Never or hardly ever
## 3196: No, not at all           No, not at all Most lessons         Some lessons
## 3197: No, not at all           No, not at all Some lessons         Some lessons
##                 ST097Q03TA           ST097Q04TA           ST097Q05TA
##    1:         Some lessons         Some lessons         Most lessons
##    2:         Some lessons Never or hardly ever         Some lessons
##    3:         Some lessons Never or hardly ever         Some lessons
##    4:         Some lessons         Some lessons         Some lessons
##    5: Never or hardly ever         Some lessons Never or hardly ever
##   ---                                                               
## 3193: Never or hardly ever Never or hardly ever Never or hardly ever
## 3194:         Some lessons Never or hardly ever Never or hardly ever
## 3195:                 <NA> Never or hardly ever         Some lessons
## 3196:         Some lessons         Some lessons         Some lessons
## 3197:         Some lessons         Some lessons         Some lessons
##            ST098Q01TA           ST098Q02TA           ST098Q03NA      ST098Q05TA
##    1: In most lessons      In some lessons Never or hardly ever            <NA>
##    2: In most lessons      In some lessons      In some lessons In some lessons
##    3:  In all lessons      In most lessons      In most lessons  In all lessons
##    4: In most lessons      In some lessons      In some lessons In most lessons
##    5: In most lessons Never or hardly ever      In most lessons In some lessons
##   ---                                                                          
## 3193: In most lessons      In some lessons      In some lessons In most lessons
## 3194:  In all lessons      In some lessons       In all lessons In most lessons
## 3195:  In all lessons      In some lessons Never or hardly ever In some lessons
## 3196:  In all lessons      In some lessons      In some lessons  In all lessons
## 3197:  In all lessons      In most lessons       In all lessons In most lessons
##                 ST098Q06TA           ST098Q07TA           ST098Q08NA
##    1:      In most lessons Never or hardly ever Never or hardly ever
##    2:      In some lessons      In some lessons      In most lessons
##    3:       In all lessons      In some lessons      In some lessons
##    4:      In most lessons Never or hardly ever      In some lessons
##    5:      In most lessons      In some lessons      In most lessons
##   ---                                                               
## 3193:      In some lessons Never or hardly ever      In some lessons
## 3194:      In most lessons      In most lessons      In most lessons
## 3195: Never or hardly ever Never or hardly ever Never or hardly ever
## 3196:      In most lessons Never or hardly ever      In some lessons
## 3197:       In all lessons      In most lessons      In most lessons
##                 ST098Q09TA           ST098Q10NA           ST100Q01TA
##    1: Never or hardly ever      In some lessons         Some lessons
##    2: Never or hardly ever Never or hardly ever         Every lesson
##    3:      In most lessons      In most lessons         Every lesson
##    4:      In most lessons      In some lessons         Every lesson
##    5:      In most lessons      In most lessons         Some lessons
##   ---                                                               
## 3193:      In most lessons Never or hardly ever         Every lesson
## 3194:      In most lessons      In most lessons         Most lessons
## 3195: Never or hardly ever Never or hardly ever         Some lessons
## 3196: Never or hardly ever      In most lessons Never or hardly ever
## 3197:       In all lessons      In some lessons         Most lessons
##         ST100Q02TA           ST100Q03TA           ST100Q04TA
##    1: Most lessons         Some lessons         Most lessons
##    2: Every lesson         Most lessons         Every lesson
##    3: Every lesson         Every lesson         Every lesson
##    4: Every lesson         Every lesson         Most lessons
##    5: Most lessons         Most lessons         Some lessons
##   ---                                                       
## 3193: Every lesson         Most lessons         Every lesson
## 3194: Every lesson         Every lesson         Every lesson
## 3195: Most lessons         Most lessons         Most lessons
## 3196: Most lessons         Some lessons Never or hardly ever
## 3197: Some lessons Never or hardly ever         Some lessons
##                 ST100Q05TA                          ST103Q01NA
##    1: Never or hardly ever                        Some lessons
##    2:         Most lessons                        Many lessons
##    3:         Every lesson Every lesson or almost every lesson
##    4:         Most lessons                        Many lessons
##    5:         Most lessons                        Many lessons
##   ---                                                         
## 3193:         Every lesson                        Many lessons
## 3194:         Every lesson Every lesson or almost every lesson
## 3195:         Most lessons               Never or almost never
## 3196:         Most lessons                        Some lessons
## 3197:         Every lesson                        Some lessons
##                                ST103Q03NA                          ST103Q08NA
##    1:               Never or almost never                        Some lessons
##    2:                        Some lessons                        Some lessons
##    3:               Never or almost never                        Many lessons
##    4:                        Many lessons                        Many lessons
##    5:                        Some lessons                        Many lessons
##   ---                                                                        
## 3193:                        Many lessons                        Many lessons
## 3194: Every lesson or almost every lesson Every lesson or almost every lesson
## 3195:               Never or almost never                        Some lessons
## 3196:                        Many lessons                        Many lessons
## 3197: Every lesson or almost every lesson Every lesson or almost every lesson
##                                ST103Q11NA                          ST104Q01NA
##    1:                        Some lessons               Never or almost never
##    2:               Never or almost never                        Some lessons
##    3: Every lesson or almost every lesson Every lesson or almost every lesson
##    4:               Never or almost never                        Some lessons
##    5:                        Some lessons                        Some lessons
##   ---                                                                        
## 3193:                        Some lessons                        Some lessons
## 3194: Every lesson or almost every lesson                        Some lessons
## 3195:               Never or almost never                        Some lessons
## 3196:                        Some lessons                        Some lessons
## 3197:                        Some lessons                        Some lessons
##                  ST104Q02NA            ST104Q03NA            ST104Q04NA
##    1: Never or almost never Never or almost never Never or almost never
##    2: Never or almost never Never or almost never                  <NA>
##    3: Never or almost never          Some lessons          Some lessons
##    4:          Some lessons          Some lessons          Some lessons
##    5: Never or almost never Never or almost never Never or almost never
##   ---                                                                  
## 3193: Never or almost never Never or almost never          Some lessons
## 3194:          Some lessons          Some lessons          Some lessons
## 3195: Never or almost never          Some lessons          Some lessons
## 3196: Never or almost never          Some lessons Never or almost never
## 3197:          Some lessons          Some lessons          Some lessons
##                  ST104Q05NA                          ST107Q01NA
##    1: Never or almost never               Never or almost never
##    2: Never or almost never                        Many lessons
##    3:          Some lessons                        Some lessons
##    4:          Some lessons                        Many lessons
##    5: Never or almost never                        Some lessons
##   ---                                                          
## 3193:          Some lessons                        Many lessons
## 3194:          Some lessons                        Many lessons
## 3195: Never or almost never               Never or almost never
## 3196: Never or almost never               Never or almost never
## 3197:          Some lessons Every lesson or almost every lesson
##                                ST107Q02NA            ST107Q03NA
##    1: Every lesson or almost every lesson          Some lessons
##    2:               Never or almost never Never or almost never
##    3: Every lesson or almost every lesson Never or almost never
##    4:                        Many lessons          Some lessons
##    5:               Never or almost never          Many lessons
##   ---                                                          
## 3193:                        Many lessons          Many lessons
## 3194:                        Many lessons          Some lessons
## 3195:                        Some lessons Never or almost never
## 3196:               Never or almost never Never or almost never
## 3197:                        Many lessons          Many lessons
##                                                                               ST092Q01TA
##    1:                                                         I have never heard of this
##    2:                                                         I have never heard of this
##    3:                    I know something about this and could explain the general issue
##    4: I have heard about this but I would not be able to explain what it is really about
##    5:                    I know something about this and could explain the general issue
##   ---                                                                                   
## 3193:                   I am familiar with this and I would be able to explain this well
## 3194:                    I know something about this and could explain the general issue
## 3195:                    I know something about this and could explain the general issue
## 3196:                   I am familiar with this and I would be able to explain this well
## 3197:                   I am familiar with this and I would be able to explain this well
##                                                                               ST092Q02TA
##    1: I have heard about this but I would not be able to explain what it is really about
##    2:                                                         I have never heard of this
##    3:                                                         I have never heard of this
##    4: I have heard about this but I would not be able to explain what it is really about
##    5:                                                         I have never heard of this
##   ---                                                                                   
## 3193:                                                         I have never heard of this
## 3194: I have heard about this but I would not be able to explain what it is really about
## 3195: I have heard about this but I would not be able to explain what it is really about
## 3196:                    I know something about this and could explain the general issue
## 3197:                    I know something about this and could explain the general issue
##                                                                               ST092Q04TA
##    1: I have heard about this but I would not be able to explain what it is really about
##    2: I have heard about this but I would not be able to explain what it is really about
##    3: I have heard about this but I would not be able to explain what it is really about
##    4:                    I know something about this and could explain the general issue
##    5:                    I know something about this and could explain the general issue
##   ---                                                                                   
## 3193:                   I am familiar with this and I would be able to explain this well
## 3194:                    I know something about this and could explain the general issue
## 3195:                   I am familiar with this and I would be able to explain this well
## 3196:                   I am familiar with this and I would be able to explain this well
## 3197:                   I am familiar with this and I would be able to explain this well
##                                                                               ST092Q05TA
##    1:                    I know something about this and could explain the general issue
##    2: I have heard about this but I would not be able to explain what it is really about
##    3:                   I am familiar with this and I would be able to explain this well
##    4:                    I know something about this and could explain the general issue
##    5:                   I am familiar with this and I would be able to explain this well
##   ---                                                                                   
## 3193:                   I am familiar with this and I would be able to explain this well
## 3194: I have heard about this but I would not be able to explain what it is really about
## 3195:                   I am familiar with this and I would be able to explain this well
## 3196:                   I am familiar with this and I would be able to explain this well
## 3197:                   I am familiar with this and I would be able to explain this well
##                                                             ST092Q06NA
##    1:  I know something about this and could explain the general issue
##    2:  I know something about this and could explain the general issue
##    3: I am familiar with this and I would be able to explain this well
##    4:  I know something about this and could explain the general issue
##    5:  I know something about this and could explain the general issue
##   ---                                                                 
## 3193:  I know something about this and could explain the general issue
## 3194:  I know something about this and could explain the general issue
## 3195: I am familiar with this and I would be able to explain this well
## 3196: I am familiar with this and I would be able to explain this well
## 3197:  I know something about this and could explain the general issue
##                                                                               ST092Q08NA
##    1:                    I know something about this and could explain the general issue
##    2:                    I know something about this and could explain the general issue
##    3:                    I know something about this and could explain the general issue
##    4:                    I know something about this and could explain the general issue
##    5: I have heard about this but I would not be able to explain what it is really about
##   ---                                                                                   
## 3193:                    I know something about this and could explain the general issue
## 3194:                    I know something about this and could explain the general issue
## 3195:                   I am familiar with this and I would be able to explain this well
## 3196:                   I am familiar with this and I would be able to explain this well
## 3197:                    I know something about this and could explain the general issue
##                                                                               ST092Q09NA
##    1:                    I know something about this and could explain the general issue
##    2:                    I know something about this and could explain the general issue
##    3:                    I know something about this and could explain the general issue
##    4:                    I know something about this and could explain the general issue
##    5: I have heard about this but I would not be able to explain what it is really about
##   ---                                                                                   
## 3193:                   I am familiar with this and I would be able to explain this well
## 3194: I have heard about this but I would not be able to explain what it is really about
## 3195:                   I am familiar with this and I would be able to explain this well
## 3196:                   I am familiar with this and I would be able to explain this well
## 3197:                   I am familiar with this and I would be able to explain this well
##                ST093Q01TA          ST093Q03TA          ST093Q04TA
##    1:           Get worse           Get worse           Get worse
##    2:           Get worse           Get worse           Get worse
##    3:           Get worse           Get worse Stay about the same
##    4:           Get worse           Get worse           Get worse
##    5:           Get worse Stay about the same           Get worse
##   ---                                                            
## 3193:           Get worse           Get worse           Get worse
## 3194: Stay about the same Stay about the same           Get worse
## 3195:           Get worse           Get worse           Get worse
## 3196:             Improve           Get worse Stay about the same
## 3197: Stay about the same           Get worse           Get worse
##                ST093Q05TA          ST093Q06TA          ST093Q07NA
##    1: Stay about the same Stay about the same Stay about the same
##    2: Stay about the same Stay about the same Stay about the same
##    3: Stay about the same             Improve             Improve
##    4: Stay about the same           Get worse           Get worse
##    5:           Get worse           Get worse           Get worse
##   ---                                                            
## 3193:           Get worse           Get worse           Get worse
## 3194: Stay about the same Stay about the same           Get worse
## 3195:           Get worse             Improve           Get worse
## 3196: Stay about the same             Improve             Improve
## 3197:                <NA>             Improve           Get worse
##                ST093Q08NA        ST094Q01NA        ST094Q02NA        ST094Q03NA
##    1: Stay about the same          Disagree          Disagree          Disagree
##    2: Stay about the same Strongly disagree Strongly disagree Strongly disagree
##    3: Stay about the same          Disagree Strongly disagree Strongly disagree
##    4:           Get worse          Disagree          Disagree          Disagree
##    5:             Improve    Strongly agree          Disagree          Disagree
##   ---                                                                          
## 3193:           Get worse    Strongly agree             Agree             Agree
## 3194:           Get worse    Strongly agree    Strongly agree             Agree
## 3195: Stay about the same          Disagree              <NA> Strongly disagree
## 3196:           Get worse             Agree             Agree          Disagree
## 3197: Stay about the same          Disagree             Agree             Agree
##              ST094Q04NA        ST094Q05NA        ST095Q04NA        ST095Q07NA
##    1:          Disagree          Disagree    Not interested Hardly interested
##    2: Strongly disagree Strongly disagree        Interested    Not interested
##    3: Strongly disagree Strongly disagree Hardly interested Hardly interested
##    4:          Disagree          Disagree        Interested        Interested
##    5:             Agree    Strongly agree Hardly interested Hardly interested
##   ---                                                                        
## 3193:             Agree             Agree Highly interested        Interested
## 3194:             Agree    Strongly agree        Interested Hardly interested
## 3195: Strongly disagree Strongly disagree Hardly interested    Not interested
## 3196:          Disagree             Agree Hardly interested    Not interested
## 3197:          Disagree    Strongly agree        Interested        Interested
##              ST095Q08NA                ST095Q13NA        ST095Q15NA
##    1:    Not interested         Highly interested        Interested
##    2:    Not interested            Not interested    Not interested
##    3: Hardly interested I don't know what this is        Interested
##    4:    Not interested         Highly interested        Interested
##    5:        Interested                Interested Highly interested
##   ---                                                              
## 3193:        Interested         Highly interested Highly interested
## 3194: Hardly interested                Interested        Interested
## 3195: Hardly interested         Hardly interested        Interested
## 3196:    Not interested                Interested Highly interested
## 3197: Highly interested         Highly interested Highly interested
##              ST113Q01TA        ST113Q02TA        ST113Q03TA        ST113Q04TA
##    1:              <NA>              <NA>              <NA>              <NA>
##    2: Strongly Disagree Strongly Disagree Strongly Disagree Strongly Disagree
##    3:             Agree             Agree Strongly Disagree Strongly Disagree
##    4:             Agree          Disagree Strongly Disagree          Disagree
##    5:          Disagree          Disagree             Agree             Agree
##   ---                                                                        
## 3193:             Agree             Agree    Strongly Agree    Strongly Agree
## 3194:             Agree          Disagree          Disagree          Disagree
## 3195:          Disagree             Agree Strongly Disagree Strongly Disagree
## 3196:          Disagree Strongly Disagree          Disagree          Disagree
## 3197:    Strongly Agree    Strongly Agree    Strongly Agree    Strongly Agree
##                                 ST129Q01TA
##    1:                                 <NA>
##    2:                   I couldn't do this
##    3:                   I couldn't do this
##    4: I could do this with a bit of effort
##    5: I could do this with a bit of effort
##   ---                                     
## 3193: I could do this with a bit of effort
## 3194: I could do this with a bit of effort
## 3195:               I could do this easily
## 3196: I could do this with a bit of effort
## 3197: I could do this with a bit of effort
##                                  ST129Q02TA
##    1:                                  <NA>
##    2:                    I couldn't do this
##    3:  I could do this with a bit of effort
##    4:                I could do this easily
##    5: I would struggle to do this on my own
##   ---                                      
## 3193:                I could do this easily
## 3194:  I could do this with a bit of effort
## 3195:                I could do this easily
## 3196:                I could do this easily
## 3197: I would struggle to do this on my own
##                                  ST129Q03TA
##    1:                                  <NA>
##    2: I would struggle to do this on my own
##    3:                    I couldn't do this
##    4: I would struggle to do this on my own
##    5: I would struggle to do this on my own
##   ---                                      
## 3193:  I could do this with a bit of effort
## 3194: I would struggle to do this on my own
## 3195:                I could do this easily
## 3196:  I could do this with a bit of effort
## 3197:                I could do this easily
##                                  ST129Q04TA
##    1:                                  <NA>
##    2:                    I couldn't do this
##    3: I would struggle to do this on my own
##    4:                    I couldn't do this
##    5: I would struggle to do this on my own
##   ---                                      
## 3193: I would struggle to do this on my own
## 3194: I would struggle to do this on my own
## 3195:                I could do this easily
## 3196:  I could do this with a bit of effort
## 3197:                I could do this easily
##                                  ST129Q05TA
##    1:                                  <NA>
##    2:                    I couldn't do this
##    3:                    I couldn't do this
##    4:  I could do this with a bit of effort
##    5:  I could do this with a bit of effort
##   ---                                      
## 3193:  I could do this with a bit of effort
## 3194: I would struggle to do this on my own
## 3195:                                  <NA>
## 3196:                I could do this easily
## 3197:  I could do this with a bit of effort
##                                  ST129Q06TA
##    1:                                  <NA>
##    2:                    I couldn't do this
##    3:                    I couldn't do this
##    4:                I could do this easily
##    5: I would struggle to do this on my own
##   ---                                      
## 3193:                    I couldn't do this
## 3194: I would struggle to do this on my own
## 3195:                I could do this easily
## 3196:  I could do this with a bit of effort
## 3197:                I could do this easily
##                                  ST129Q07TA
##    1:                                  <NA>
##    2:                    I couldn't do this
##    3:                    I couldn't do this
##    4: I would struggle to do this on my own
##    5: I would struggle to do this on my own
##   ---                                      
## 3193:                    I couldn't do this
## 3194: I would struggle to do this on my own
## 3195:  I could do this with a bit of effort
## 3196:  I could do this with a bit of effort
## 3197:  I could do this with a bit of effort
##                                  ST129Q08TA     ST131Q01NA     ST131Q03NA
##    1:                                  <NA>           <NA>           <NA>
##    2:                    I couldn't do this Strongly agree          Agree
##    3:                    I couldn't do this Strongly agree       Disagree
##    4:                    I couldn't do this Strongly agree Strongly agree
##    5: I would struggle to do this on my own       Disagree Strongly agree
##   ---                                                                    
## 3193: I would struggle to do this on my own          Agree          Agree
## 3194: I would struggle to do this on my own          Agree       Disagree
## 3195:  I could do this with a bit of effort       Disagree          Agree
## 3196:                I could do this easily Strongly agree          Agree
## 3197: I would struggle to do this on my own Strongly agree Strongly agree
##           ST131Q04NA     ST131Q06NA     ST131Q08NA     ST131Q11NA
##    1:           <NA>           <NA>           <NA>           <NA>
##    2:          Agree       Disagree       Disagree           <NA>
##    3: Strongly agree Strongly agree          Agree          Agree
##    4: Strongly agree          Agree          Agree          Agree
##    5:          Agree Strongly agree          Agree          Agree
##   ---                                                            
## 3193:          Agree       Disagree       Disagree       Disagree
## 3194:          Agree          Agree          Agree       Disagree
## 3195:          Agree       Disagree       Disagree       Disagree
## 3196:          Agree       Disagree Strongly agree Strongly agree
## 3197: Strongly agree Strongly agree Strongly agree Strongly agree
##                 ST146Q01TA           ST146Q02TA           ST146Q03TA
##    1:                 <NA>                 <NA>                 <NA>
##    2: Never or hardly ever Never or hardly ever Never or hardly ever
##    3: Never or hardly ever Never or hardly ever Never or hardly ever
##    4: Never or hardly ever Never or hardly ever Never or hardly ever
##    5: Never or hardly ever Never or hardly ever Never or hardly ever
##   ---                                                               
## 3193:            Sometimes            Sometimes            Sometimes
## 3194:            Sometimes            Sometimes            Sometimes
## 3195:            Sometimes Never or hardly ever Never or hardly ever
## 3196:            Sometimes Never or hardly ever            Sometimes
## 3197: Never or hardly ever Never or hardly ever            Sometimes
##                 ST146Q04TA           ST146Q05TA           ST146Q06NA
##    1:                 <NA>                 <NA>                 <NA>
##    2: Never or hardly ever Never or hardly ever Never or hardly ever
##    3: Never or hardly ever Never or hardly ever Never or hardly ever
##    4: Never or hardly ever Never or hardly ever Never or hardly ever
##    5:            Sometimes Never or hardly ever Never or hardly ever
##   ---                                                               
## 3193:            Sometimes Never or hardly ever Never or hardly ever
## 3194:            Sometimes Never or hardly ever Never or hardly ever
## 3195:            Sometimes Never or hardly ever Never or hardly ever
## 3196:            Sometimes            Sometimes Never or hardly ever
## 3197:            Sometimes Never or hardly ever Never or hardly ever
##                 ST146Q07NA           ST146Q08NA           ST146Q09NA ST076Q01NA
##    1:                 <NA>                 <NA>                 <NA>       <NA>
##    2: Never or hardly ever Never or hardly ever Never or hardly ever        Yes
##    3: Never or hardly ever Never or hardly ever Never or hardly ever        Yes
##    4: Never or hardly ever            Sometimes            Sometimes         No
##    5: Never or hardly ever Never or hardly ever Never or hardly ever        Yes
##   ---                                                                          
## 3193: Never or hardly ever            Sometimes            Sometimes        Yes
## 3194: Never or hardly ever Never or hardly ever Never or hardly ever         No
## 3195: Never or hardly ever                 <NA>            Regularly         No
## 3196: Never or hardly ever Never or hardly ever            Regularly         No
## 3197: Never or hardly ever            Sometimes Never or hardly ever        Yes
##       ST076Q02NA ST076Q03NA ST076Q04NA ST076Q05NA ST076Q06NA ST076Q07NA
##    1:       <NA>       <NA>       <NA>       <NA>       <NA>       <NA>
##    2:         No         No         No         No         No         No
##    3:         No         No         No        Yes         No         No
##    4:         No         No         No        Yes         No         No
##    5:         No         No        Yes         No         No         No
##   ---                                                                  
## 3193:         No         No        Yes         No         No         No
## 3194:         No         No         No        Yes         No         No
## 3195:         No         No         No        Yes         No         No
## 3196:         No        Yes        Yes        Yes        Yes        Yes
## 3197:        Yes        Yes        Yes        Yes        Yes         No
##       ST076Q08NA ST076Q09NA ST076Q10NA ST076Q11NA ST078Q01NA ST078Q02NA
##    1:       <NA>       <NA>       <NA>       <NA>       <NA>       <NA>
##    2:        Yes        Yes         No         No       <NA>       <NA>
##    3:        Yes         No         No         No        Yes        Yes
##    4:        Yes         No         No         No        Yes        Yes
##    5:        Yes         No         No         No        Yes        Yes
##   ---                                                                  
## 3193:        Yes         No         No         No        Yes        Yes
## 3194:         No         No         No         No        Yes        Yes
## 3195:         No         No         No        Yes        Yes         No
## 3196:        Yes        Yes         No         No        Yes         No
## 3197:        Yes        Yes         No        Yes        Yes        Yes
##       ST078Q03NA ST078Q04NA ST078Q05NA ST078Q06NA ST078Q07NA ST078Q08NA
##    1:       <NA>       <NA>       <NA>       <NA>       <NA>       <NA>
##    2:       <NA>       <NA>       <NA>       <NA>       <NA>       <NA>
##    3:        Yes        Yes        Yes         No        Yes        Yes
##    4:        Yes        Yes        Yes         No        Yes        Yes
##    5:        Yes         No        Yes         No         No        Yes
##   ---                                                                  
## 3193:        Yes        Yes        Yes         No        Yes        Yes
## 3194:        Yes        Yes        Yes         No        Yes        Yes
## 3195:        Yes         No        Yes         No         No        Yes
## 3196:        Yes        Yes        Yes        Yes        Yes        Yes
## 3197:         No        Yes        Yes        Yes         No        Yes
##       ST078Q09NA ST078Q10NA ST078Q11NA ST065Class IC001Q01TA IC001Q02TA
##    1:       <NA>       <NA>       <NA>  Chemistry       <NA>       <NA>
##    2:       <NA>       <NA>       <NA>  Chemistry       <NA>       <NA>
##    3:        Yes         No         No  Chemistry       <NA>       <NA>
##    4:        Yes         No        Yes  Chemistry       <NA>       <NA>
##    5:        Yes         No        Yes  Chemistry       <NA>       <NA>
##   ---                                                                  
## 3193:        Yes         No        Yes    Physics       <NA>       <NA>
## 3194:        Yes         No        Yes    Biology       <NA>       <NA>
## 3195:         No         No        Yes    Biology       <NA>       <NA>
## 3196:        Yes        Yes         No    Biology       <NA>       <NA>
## 3197:        Yes         No        Yes    Biology       <NA>       <NA>
##       IC001Q03TA IC001Q04TA IC001Q05TA IC001Q06TA IC001Q07TA IC001Q08TA
##    1:       <NA>       <NA>       <NA>       <NA>       <NA>       <NA>
##    2:       <NA>       <NA>       <NA>       <NA>       <NA>       <NA>
##    3:       <NA>       <NA>       <NA>       <NA>       <NA>       <NA>
##    4:       <NA>       <NA>       <NA>       <NA>       <NA>       <NA>
##    5:       <NA>       <NA>       <NA>       <NA>       <NA>       <NA>
##   ---                                                                  
## 3193:       <NA>       <NA>       <NA>       <NA>       <NA>       <NA>
## 3194:       <NA>       <NA>       <NA>       <NA>       <NA>       <NA>
## 3195:       <NA>       <NA>       <NA>       <NA>       <NA>       <NA>
## 3196:       <NA>       <NA>       <NA>       <NA>       <NA>       <NA>
## 3197:       <NA>       <NA>       <NA>       <NA>       <NA>       <NA>
##       IC001Q09TA IC001Q10TA IC001Q11TA IC009Q01TA IC009Q02TA IC009Q03TA
##    1:       <NA>       <NA>       <NA>       <NA>       <NA>       <NA>
##    2:       <NA>       <NA>       <NA>       <NA>       <NA>       <NA>
##    3:       <NA>       <NA>       <NA>       <NA>       <NA>       <NA>
##    4:       <NA>       <NA>       <NA>       <NA>       <NA>       <NA>
##    5:       <NA>       <NA>       <NA>       <NA>       <NA>       <NA>
##   ---                                                                  
## 3193:       <NA>       <NA>       <NA>       <NA>       <NA>       <NA>
## 3194:       <NA>       <NA>       <NA>       <NA>       <NA>       <NA>
## 3195:       <NA>       <NA>       <NA>       <NA>       <NA>       <NA>
## 3196:       <NA>       <NA>       <NA>       <NA>       <NA>       <NA>
## 3197:       <NA>       <NA>       <NA>       <NA>       <NA>       <NA>
##       IC009Q05NA IC009Q06NA IC009Q07NA IC009Q08TA IC009Q09TA IC009Q10NA
##    1:       <NA>       <NA>       <NA>       <NA>       <NA>       <NA>
##    2:       <NA>       <NA>       <NA>       <NA>       <NA>       <NA>
##    3:       <NA>       <NA>       <NA>       <NA>       <NA>       <NA>
##    4:       <NA>       <NA>       <NA>       <NA>       <NA>       <NA>
##    5:       <NA>       <NA>       <NA>       <NA>       <NA>       <NA>
##   ---                                                                  
## 3193:       <NA>       <NA>       <NA>       <NA>       <NA>       <NA>
## 3194:       <NA>       <NA>       <NA>       <NA>       <NA>       <NA>
## 3195:       <NA>       <NA>       <NA>       <NA>       <NA>       <NA>
## 3196:       <NA>       <NA>       <NA>       <NA>       <NA>       <NA>
## 3197:       <NA>       <NA>       <NA>       <NA>       <NA>       <NA>
##       IC009Q11NA IC002Q01NA IC003Q01TA IC004Q01TA IC005Q01TA IC006Q01TA
##    1:       <NA>       <NA>       <NA>       <NA>       <NA>       <NA>
##    2:       <NA>       <NA>       <NA>       <NA>       <NA>       <NA>
##    3:       <NA>       <NA>       <NA>       <NA>       <NA>       <NA>
##    4:       <NA>       <NA>       <NA>       <NA>       <NA>       <NA>
##    5:       <NA>       <NA>       <NA>       <NA>       <NA>       <NA>
##   ---                                                                  
## 3193:       <NA>       <NA>       <NA>       <NA>       <NA>       <NA>
## 3194:       <NA>       <NA>       <NA>       <NA>       <NA>       <NA>
## 3195:       <NA>       <NA>       <NA>       <NA>       <NA>       <NA>
## 3196:       <NA>       <NA>       <NA>       <NA>       <NA>       <NA>
## 3197:       <NA>       <NA>       <NA>       <NA>       <NA>       <NA>
##       IC007Q01TA            IC008Q01TA           IC008Q02TA
##    1:       <NA>  Never or hardly ever Never or hardly ever
##    2:       <NA>  Never or hardly ever Never or hardly ever
##    3:       <NA>  Never or hardly ever Never or hardly ever
##    4:       <NA>  Never or hardly ever Never or hardly ever
##    5:       <NA> Once or twice a month Never or hardly ever
##   ---                                                      
## 3193:       <NA>  Never or hardly ever Never or hardly ever
## 3194:       <NA> Once or twice a month Never or hardly ever
## 3195:       <NA>  Never or hardly ever Never or hardly ever
## 3196:       <NA>      Almost every day     Almost every day
## 3197:       <NA>             Every day     Almost every day
##                  IC008Q03TA            IC008Q04TA           IC008Q05TA
##    1:  Once or twice a week             Every day            Every day
##    2:  Once or twice a week             Every day            Every day
##    3:                  <NA>      Almost every day            Every day
##    4:      Almost every day             Every day            Every day
##    5:  Once or twice a week Once or twice a month            Every day
##   ---                                                                 
## 3193:  Never or hardly ever  Never or hardly ever Once or twice a week
## 3194:      Almost every day  Never or hardly ever     Almost every day
## 3195: Once or twice a month  Never or hardly ever            Every day
## 3196: Once or twice a month             Every day Once or twice a week
## 3197:      Almost every day  Never or hardly ever Once or twice a week
##                 IC008Q07NA            IC008Q08TA            IC008Q09TA
##    1: Never or hardly ever             Every day  Never or hardly ever
##    2: Never or hardly ever      Almost every day Once or twice a month
##    3: Never or hardly ever             Every day Once or twice a month
##    4: Never or hardly ever             Every day  Once or twice a week
##    5: Never or hardly ever             Every day  Never or hardly ever
##   ---                                                                 
## 3193: Never or hardly ever Once or twice a month  Never or hardly ever
## 3194: Never or hardly ever  Once or twice a week  Once or twice a week
## 3195: Never or hardly ever      Almost every day  Once or twice a week
## 3196: Never or hardly ever             Every day      Almost every day
## 3197: Never or hardly ever             Every day  Once or twice a week
##                  IC008Q10TA            IC008Q11TA            IC008Q12TA
##    1:  Once or twice a week  Once or twice a week  Never or hardly ever
##    2:  Never or hardly ever  Never or hardly ever  Never or hardly ever
##    3:      Almost every day             Every day      Almost every day
##    4:      Almost every day      Almost every day             Every day
##    5:             Every day      Almost every day  Never or hardly ever
##   ---                                                                  
## 3193: Once or twice a month  Once or twice a week  Never or hardly ever
## 3194:  Once or twice a week Once or twice a month  Never or hardly ever
## 3195:  Once or twice a week  Never or hardly ever  Never or hardly ever
## 3196:      Almost every day             Every day  Once or twice a week
## 3197:             Every day      Almost every day Once or twice a month
##                  IC008Q13NA            IC010Q01TA            IC010Q02NA
##    1:  Never or hardly ever  Once or twice a week  Once or twice a week
##    2: Once or twice a month Once or twice a month Once or twice a month
##    3:      Almost every day      Almost every day      Almost every day
##    4:      Almost every day  Once or twice a week Once or twice a month
##    5: Once or twice a month      Almost every day  Once or twice a week
##   ---                                                                  
## 3193: Once or twice a month  Once or twice a week Once or twice a month
## 3194: Once or twice a month Once or twice a month Once or twice a month
## 3195:      Almost every day Once or twice a month  Never or hardly ever
## 3196: Once or twice a month      Almost every day Once or twice a month
## 3197: Once or twice a month      Almost every day  Once or twice a week
##                  IC010Q03TA            IC010Q04TA            IC010Q05NA
##    1: Once or twice a month  Never or hardly ever Once or twice a month
##    2:  Never or hardly ever  Never or hardly ever      Almost every day
##    3:      Almost every day Once or twice a month             Every day
##    4:  Never or hardly ever  Never or hardly ever             Every day
##    5:  Never or hardly ever  Never or hardly ever  Once or twice a week
##   ---                                                                  
## 3193:  Never or hardly ever  Never or hardly ever  Once or twice a week
## 3194:      Almost every day  Never or hardly ever  Never or hardly ever
## 3195:  Never or hardly ever  Never or hardly ever             Every day
## 3196:  Once or twice a week      Almost every day      Almost every day
## 3197:      Almost every day  Never or hardly ever             Every day
##                  IC010Q06NA            IC010Q07TA            IC010Q08TA
##    1:  Never or hardly ever  Never or hardly ever  Never or hardly ever
##    2:  Never or hardly ever  Never or hardly ever  Never or hardly ever
##    3: Once or twice a month Once or twice a month Once or twice a month
##    4:  Never or hardly ever Once or twice a month Once or twice a month
##    5:  Never or hardly ever                  <NA>  Never or hardly ever
##   ---                                                                  
## 3193:  Never or hardly ever  Never or hardly ever  Never or hardly ever
## 3194:  Never or hardly ever  Never or hardly ever  Never or hardly ever
## 3195:  Never or hardly ever  Never or hardly ever  Never or hardly ever
## 3196:  Never or hardly ever  Never or hardly ever  Never or hardly ever
## 3197:  Never or hardly ever  Never or hardly ever  Never or hardly ever
##                  IC010Q09NA            IC010Q10NA            IC010Q11NA
##    1:  Never or hardly ever  Never or hardly ever  Never or hardly ever
##    2:  Never or hardly ever  Never or hardly ever  Never or hardly ever
##    3: Once or twice a month Once or twice a month  Never or hardly ever
##    4:  Once or twice a week  Once or twice a week Once or twice a month
##    5:  Once or twice a week  Never or hardly ever  Never or hardly ever
##   ---                                                                  
## 3193: Once or twice a month Once or twice a month  Never or hardly ever
## 3194: Once or twice a month Once or twice a month  Never or hardly ever
## 3195: Once or twice a month  Once or twice a week  Never or hardly ever
## 3196:  Once or twice a week  Once or twice a week  Never or hardly ever
## 3197:  Once or twice a week  Never or hardly ever  Never or hardly ever
##                 IC010Q12NA           IC011Q01TA            IC011Q02TA
##    1: Never or hardly ever Never or hardly ever  Never or hardly ever
##    2: Never or hardly ever Never or hardly ever  Never or hardly ever
##    3: Never or hardly ever Never or hardly ever  Never or hardly ever
##    4: Never or hardly ever Never or hardly ever  Never or hardly ever
##    5: Never or hardly ever Never or hardly ever  Never or hardly ever
##   ---                                                                
## 3193: Never or hardly ever Never or hardly ever  Never or hardly ever
## 3194: Never or hardly ever Never or hardly ever Once or twice a month
## 3195: Never or hardly ever Never or hardly ever  Never or hardly ever
## 3196: Never or hardly ever Once or twice a week  Never or hardly ever
## 3197: Never or hardly ever Never or hardly ever  Never or hardly ever
##                  IC011Q03TA            IC011Q04TA           IC011Q05TA
##    1:  Never or hardly ever  Never or hardly ever Never or hardly ever
##    2: Once or twice a month Once or twice a month Never or hardly ever
##    3: Once or twice a month Once or twice a month Never or hardly ever
##    4:  Once or twice a week Once or twice a month Never or hardly ever
##    5: Once or twice a month  Never or hardly ever Never or hardly ever
##   ---                                                                 
## 3193: Once or twice a month  Never or hardly ever Never or hardly ever
## 3194: Once or twice a month  Never or hardly ever Never or hardly ever
## 3195: Once or twice a month Once or twice a month Never or hardly ever
## 3196: Once or twice a month  Never or hardly ever Never or hardly ever
## 3197: Once or twice a month  Never or hardly ever Never or hardly ever
##                 IC011Q06TA            IC011Q07TA           IC011Q08TA
##    1: Never or hardly ever  Never or hardly ever Never or hardly ever
##    2: Never or hardly ever Once or twice a month Never or hardly ever
##    3: Never or hardly ever  Never or hardly ever Never or hardly ever
##    4: Never or hardly ever  Never or hardly ever Never or hardly ever
##    5: Never or hardly ever  Never or hardly ever Never or hardly ever
##   ---                                                                
## 3193: Never or hardly ever                  <NA> Never or hardly ever
## 3194: Never or hardly ever  Never or hardly ever Never or hardly ever
## 3195: Never or hardly ever  Never or hardly ever Never or hardly ever
## 3196: Never or hardly ever  Never or hardly ever Never or hardly ever
## 3197: Never or hardly ever  Never or hardly ever Never or hardly ever
##                  IC011Q09TA     IC013Q01NA     IC013Q04NA     IC013Q05NA
##    1:  Never or hardly ever          Agree Strongly agree          Agree
##    2:  Never or hardly ever Strongly agree Strongly agree Strongly agree
##    3:  Never or hardly ever Strongly agree Strongly agree Strongly agree
##    4: Once or twice a month          Agree Strongly agree Strongly agree
##    5:  Never or hardly ever       Disagree          Agree          Agree
##   ---                                                                   
## 3193: Once or twice a month       Disagree           <NA>           <NA>
## 3194: Once or twice a month       Disagree          Agree          Agree
## 3195:  Never or hardly ever       Disagree          Agree          Agree
## 3196:  Never or hardly ever Strongly agree Strongly agree Strongly agree
## 3197: Once or twice a month Strongly agree Strongly agree Strongly agree
##           IC013Q11NA        IC013Q12NA     IC013Q13NA        IC014Q03NA
##    1:       Disagree             Agree Strongly agree          Disagree
##    2:          Agree             Agree          Agree          Disagree
##    3:       Disagree             Agree          Agree          Disagree
##    4: Strongly agree    Strongly agree Strongly agree             Agree
##    5:       Disagree    Strongly agree          Agree Strongly disagree
##   ---                                                                  
## 3193:           <NA>              <NA>           <NA>              <NA>
## 3194:       Disagree Strongly disagree       Disagree Strongly disagree
## 3195:       Disagree Strongly disagree          Agree          Disagree
## 3196: Strongly agree    Strongly agree Strongly agree    Strongly agree
## 3197: Strongly agree    Strongly agree Strongly agree    Strongly agree
##              IC014Q04NA     IC014Q06NA     IC014Q08NA        IC014Q09NA
##    1: Strongly disagree          Agree          Agree             Agree
##    2:             Agree Strongly agree       Disagree          Disagree
##    3: Strongly disagree       Disagree       Disagree Strongly disagree
##    4:          Disagree Strongly agree       Disagree          Disagree
##    5: Strongly disagree Strongly agree       Disagree Strongly disagree
##   ---                                                                  
## 3193:              <NA>           <NA>           <NA>              <NA>
## 3194:             Agree       Disagree          Agree          Disagree
## 3195:             Agree          Agree          Agree             Agree
## 3196:    Strongly agree Strongly agree          Agree             Agree
## 3197:    Strongly agree Strongly agree Strongly agree    Strongly agree
##              IC015Q02NA        IC015Q03NA     IC015Q05NA        IC015Q07NA
##    1:             Agree             Agree          Agree    Strongly agree
##    2: Strongly disagree Strongly disagree          Agree          Disagree
##    3: Strongly disagree          Disagree       Disagree Strongly disagree
##    4:             Agree          Disagree Strongly agree          Disagree
##    5:          Disagree          Disagree          Agree             Agree
##   ---                                                                     
## 3193:              <NA>              <NA>           <NA>              <NA>
## 3194:          Disagree          Disagree          Agree          Disagree
## 3195:    Strongly agree             Agree Strongly agree          Disagree
## 3196:    Strongly agree    Strongly agree Strongly agree             Agree
## 3197:    Strongly agree    Strongly agree Strongly agree    Strongly agree
##              IC015Q09NA        IC016Q01NA        IC016Q02NA        IC016Q04NA
##    1:             Agree Strongly disagree          Disagree Strongly disagree
##    2:          Disagree          Disagree             Agree Strongly disagree
##    3: Strongly disagree             Agree Strongly disagree Strongly disagree
##    4:          Disagree    Strongly agree Strongly disagree Strongly disagree
##    5:             Agree             Agree          Disagree          Disagree
##   ---                                                                        
## 3193:              <NA>              <NA>              <NA>              <NA>
## 3194:             Agree          Disagree          Disagree Strongly disagree
## 3195:             Agree Strongly disagree          Disagree             Agree
## 3196:    Strongly agree          Disagree    Strongly agree    Strongly agree
## 3197:    Strongly agree             Agree    Strongly agree          Disagree
##              IC016Q05NA        IC016Q07NA EC001Q01NA EC001Q02NA EC001Q03NA
##    1:    Strongly agree Strongly disagree         NA         NA         NA
##    2: Strongly disagree Strongly disagree          3          6         NA
##    3: Strongly disagree          Disagree          0          1          0
##    4: Strongly disagree Strongly disagree         NA          1          1
##    5:             Agree          Disagree          0          0          0
##   ---                                                                     
## 3193:              <NA>              <NA>         NA         NA         NA
## 3194: Strongly disagree Strongly disagree          0          0          0
## 3195:          Disagree          Disagree         NA         NA         NA
## 3196:    Strongly agree    Strongly agree         NA          2         NA
## 3197:             Agree    Strongly agree         NA         NA         NA
##       EC001Q04NA EC001Q05NA EC001Q06NA EC001Q07NA EC001Q08NA EC001Q09NA
##    1:         NA         NA         NA         NA         NA         NA
##    2:         NA         NA         NA         NA         NA         NA
##    3:          0          0          1          0          4          0
##    4:          2         NA         NA          4         NA         NA
##    5:          0          0          0          0          0          0
##   ---                                                                  
## 3193:         NA         NA         NA         NA         NA         NA
## 3194:          0          0          0          0          0          0
## 3195:         NA         NA         NA          2         NA          6
## 3196:         NA         NA         NA         NA         NA         NA
## 3197:          1         NA         NA         NA         NA         NA
##       EC001Q10NA EC003Q01NA EC003Q02NA EC003Q03NA EC003Q04NA EC003Q05NA
##    1:         NA       <NA>       <NA>       <NA>       <NA>       <NA>
##    2:         NA       <NA>       <NA>       <NA>       <NA>       <NA>
##    3:          0       <NA>       <NA>       <NA>       <NA>       <NA>
##    4:          1       <NA>       <NA>       <NA>       <NA>       <NA>
##    5:          0       <NA>       <NA>       <NA>       <NA>       <NA>
##   ---                                                                  
## 3193:         NA       <NA>       <NA>       <NA>       <NA>       <NA>
## 3194:          0       <NA>       <NA>       <NA>       <NA>       <NA>
## 3195:         NA       <NA>       <NA>       <NA>       <NA>       <NA>
## 3196:         NA       <NA>       <NA>       <NA>       <NA>       <NA>
## 3197:         NA       <NA>       <NA>       <NA>       <NA>       <NA>
##       EC003Q06NA EC004Q01NA EC004Q02NA EC005Q01NA EC005Q02NA EC005Q03NA
##    1:       <NA>       <NA>       <NA>       <NA>       <NA>       <NA>
##    2:       <NA>       <NA>       <NA>       <NA>       <NA>       <NA>
##    3:       <NA>       <NA>       <NA>       <NA>       <NA>       <NA>
##    4:       <NA>       <NA>       <NA>       <NA>       <NA>       <NA>
##    5:       <NA>       <NA>       <NA>       <NA>       <NA>       <NA>
##   ---                                                                  
## 3193:       <NA>       <NA>       <NA>       <NA>       <NA>       <NA>
## 3194:       <NA>       <NA>       <NA>       <NA>       <NA>       <NA>
## 3195:       <NA>       <NA>       <NA>       <NA>       <NA>       <NA>
## 3196:       <NA>       <NA>       <NA>       <NA>       <NA>       <NA>
## 3197:       <NA>       <NA>       <NA>       <NA>       <NA>       <NA>
##       EC005Q04NA EC005Q05NA EC005Q06NA EC005Q07NA EC005Q08NA EC007Q01NA
##    1:       <NA>       <NA>       <NA>       <NA>       <NA>       <NA>
##    2:       <NA>       <NA>       <NA>       <NA>       <NA>       <NA>
##    3:       <NA>       <NA>       <NA>       <NA>       <NA>       <NA>
##    4:       <NA>       <NA>       <NA>       <NA>       <NA>       <NA>
##    5:       <NA>       <NA>       <NA>       <NA>       <NA>       <NA>
##   ---                                                                  
## 3193:       <NA>       <NA>       <NA>       <NA>       <NA>       <NA>
## 3194:       <NA>       <NA>       <NA>       <NA>       <NA>       <NA>
## 3195:       <NA>       <NA>       <NA>       <NA>       <NA>       <NA>
## 3196:       <NA>       <NA>       <NA>       <NA>       <NA>       <NA>
## 3197:       <NA>       <NA>       <NA>       <NA>       <NA>       <NA>
##       EC007Q02NA EC008Q01NA EC008Q02NA EC008Q03NA EC008Q04NA EC009Q03NA
##    1:       <NA>       <NA>       <NA>       <NA>       <NA>       <NA>
##    2:       <NA>       <NA>       <NA>       <NA>       <NA>       <NA>
##    3:       <NA>       <NA>       <NA>       <NA>       <NA>       <NA>
##    4:       <NA>       <NA>       <NA>       <NA>       <NA>       <NA>
##    5:       <NA>       <NA>       <NA>       <NA>       <NA>       <NA>
##   ---                                                                  
## 3193:       <NA>       <NA>       <NA>       <NA>       <NA>       <NA>
## 3194:       <NA>       <NA>       <NA>       <NA>       <NA>       <NA>
## 3195:       <NA>       <NA>       <NA>       <NA>       <NA>       <NA>
## 3196:       <NA>       <NA>       <NA>       <NA>       <NA>       <NA>
## 3197:       <NA>       <NA>       <NA>       <NA>       <NA>       <NA>
##       EC009Q07NA EC009Q10NA EC009Q12NA EC009Q13NA EC009Q14NA EC010Q04NA
##    1:       <NA>       <NA>       <NA>       <NA>       <NA>       <NA>
##    2:       <NA>       <NA>       <NA>       <NA>       <NA>       <NA>
##    3:       <NA>       <NA>       <NA>       <NA>       <NA>       <NA>
##    4:       <NA>       <NA>       <NA>       <NA>       <NA>       <NA>
##    5:       <NA>       <NA>       <NA>       <NA>       <NA>       <NA>
##   ---                                                                  
## 3193:       <NA>       <NA>       <NA>       <NA>       <NA>       <NA>
## 3194:       <NA>       <NA>       <NA>       <NA>       <NA>       <NA>
## 3195:       <NA>       <NA>       <NA>       <NA>       <NA>       <NA>
## 3196:       <NA>       <NA>       <NA>       <NA>       <NA>       <NA>
## 3197:       <NA>       <NA>       <NA>       <NA>       <NA>       <NA>
##       EC010Q06NA EC010Q07NA EC010Q08NA EC010Q09NA EC010Q10NA EC010Q11NA
##    1:       <NA>       <NA>       <NA>       <NA>       <NA>       <NA>
##    2:       <NA>       <NA>       <NA>       <NA>       <NA>       <NA>
##    3:       <NA>       <NA>       <NA>       <NA>       <NA>       <NA>
##    4:       <NA>       <NA>       <NA>       <NA>       <NA>       <NA>
##    5:       <NA>       <NA>       <NA>       <NA>       <NA>       <NA>
##   ---                                                                  
## 3193:       <NA>       <NA>       <NA>       <NA>       <NA>       <NA>
## 3194:       <NA>       <NA>       <NA>       <NA>       <NA>       <NA>
## 3195:       <NA>       <NA>       <NA>       <NA>       <NA>       <NA>
## 3196:       <NA>       <NA>       <NA>       <NA>       <NA>       <NA>
## 3197:       <NA>       <NA>       <NA>       <NA>       <NA>       <NA>
##       EC010Q12NA EC011Q01NA EC011Q02NA EC011Q03NA EC011Q04NA EC011Q05NA
##    1:       <NA>       <NA>       <NA>       <NA>       <NA>       <NA>
##    2:       <NA>       <NA>       <NA>       <NA>       <NA>       <NA>
##    3:       <NA>       <NA>       <NA>       <NA>       <NA>       <NA>
##    4:       <NA>       <NA>       <NA>       <NA>       <NA>       <NA>
##    5:       <NA>       <NA>       <NA>       <NA>       <NA>       <NA>
##   ---                                                                  
## 3193:       <NA>       <NA>       <NA>       <NA>       <NA>       <NA>
## 3194:       <NA>       <NA>       <NA>       <NA>       <NA>       <NA>
## 3195:       <NA>       <NA>       <NA>       <NA>       <NA>       <NA>
## 3196:       <NA>       <NA>       <NA>       <NA>       <NA>       <NA>
## 3197:       <NA>       <NA>       <NA>       <NA>       <NA>       <NA>
##        EC012Q01NA EC012Q02NA  EC012Q03NA  EC012Q04NA  EC012Q05NA  EC012Q06NA
##    1:        <NA>       <NA>        <NA>        <NA>        <NA>        <NA>
##    2: Not checked    Checked Not checked Not checked Not checked Not checked
##    3:        <NA>       <NA>        <NA>        <NA>        <NA>        <NA>
##    4:        <NA>       <NA>        <NA>        <NA>        <NA>        <NA>
##    5:        <NA>       <NA>        <NA>        <NA>        <NA>        <NA>
##   ---                                                                       
## 3193:        <NA>       <NA>        <NA>        <NA>        <NA>        <NA>
## 3194:        <NA>       <NA>        <NA>        <NA>        <NA>        <NA>
## 3195:        <NA>       <NA>        <NA>        <NA>        <NA>        <NA>
## 3196:        <NA>       <NA>        <NA>        <NA>        <NA>        <NA>
## 3197:        <NA>       <NA>        <NA>        <NA>        <NA>        <NA>
##       EC012Q07NA EC012Q08NA  EC012Q09NA  EC012Q10NA  EC012Q11NA EC012Q12NA
##    1:       <NA>       <NA>        <NA>        <NA>        <NA>       <NA>
##    2:    Checked    Checked Not checked Not checked Not checked    Checked
##    3:       <NA>       <NA>        <NA>        <NA>        <NA>       <NA>
##    4:       <NA>       <NA>        <NA>        <NA>        <NA>       <NA>
##    5:       <NA>       <NA>        <NA>        <NA>        <NA>       <NA>
##   ---                                                                     
## 3193:       <NA>       <NA>        <NA>        <NA>        <NA>       <NA>
## 3194:       <NA>       <NA>        <NA>        <NA>        <NA>       <NA>
## 3195:       <NA>       <NA>        <NA>        <NA>        <NA>       <NA>
## 3196:       <NA>       <NA>        <NA>        <NA>        <NA>       <NA>
## 3197:       <NA>       <NA>        <NA>        <NA>        <NA>       <NA>
##        EC013Q01NA  EC013Q02NA  EC013Q03NA  EC013Q04NA  EC013Q05NA  EC013Q06NA
##    1: Not checked Not checked Not checked Not checked Not checked Not checked
##    2:        <NA>        <NA>        <NA>        <NA>        <NA>        <NA>
##    3:     Checked Not checked Not checked     Checked Not checked     Checked
##    4:     Checked     Checked     Checked     Checked Not checked Not checked
##    5:     Checked Not checked     Checked     Checked Not checked     Checked
##   ---                                                                        
## 3193:        <NA>        <NA>        <NA>        <NA>        <NA>        <NA>
## 3194:     Checked Not checked Not checked Not checked Not checked     Checked
## 3195:     Checked Not checked Not checked Not checked Not checked Not checked
## 3196:     Checked     Checked     Checked     Checked     Checked     Checked
## 3197:     Checked Not checked     Checked     Checked     Checked Not checked
##        EC013Q07NA  EC013Q08NA  EC013Q09NA  EC013Q10NA  EC013Q11NA  EC013Q12NA
##    1: Not checked Not checked Not checked Not checked Not checked     Checked
##    2:        <NA>        <NA>        <NA>        <NA>        <NA>        <NA>
##    3: Not checked Not checked Not checked Not checked Not checked Not checked
##    4: Not checked Not checked Not checked     Checked     Checked Not checked
##    5: Not checked     Checked Not checked     Checked     Checked     Checked
##   ---                                                                        
## 3193:        <NA>        <NA>        <NA>        <NA>        <NA>        <NA>
## 3194: Not checked Not checked Not checked     Checked Not checked Not checked
## 3195: Not checked Not checked Not checked Not checked Not checked Not checked
## 3196: Not checked     Checked Not checked     Checked     Checked     Checked
## 3197: Not checked     Checked     Checked Not checked Not checked     Checked
##        EC013Q13NA EC014Q01NA EC014Q02NA EC015Q01NA EC015Q02NA EC015Q03NA
##    1:     Checked       <NA>       <NA>       <NA>       <NA>       <NA>
##    2:        <NA>       <NA>       <NA>       <NA>       <NA>       <NA>
##    3: Not checked       <NA>       <NA>       <NA>       <NA>       <NA>
##    4: Not checked       <NA>       <NA>       <NA>       <NA>       <NA>
##    5:     Checked       <NA>       <NA>       <NA>       <NA>       <NA>
##   ---                                                                   
## 3193:        <NA>       <NA>       <NA>       <NA>       <NA>       <NA>
## 3194: Not checked       <NA>       <NA>       <NA>       <NA>       <NA>
## 3195: Not checked       <NA>       <NA>       <NA>       <NA>       <NA>
## 3196:     Checked       <NA>       <NA>       <NA>       <NA>       <NA>
## 3197:     Checked       <NA>       <NA>       <NA>       <NA>       <NA>
##       EC015Q04NA EC015Q05NA EC015Q06NA EC015Q07NA EC015Q08NA EC017Q01NA
##    1:       <NA>       <NA>       <NA>       <NA>       <NA>       <NA>
##    2:       <NA>       <NA>       <NA>       <NA>       <NA>       <NA>
##    3:       <NA>       <NA>       <NA>       <NA>       <NA>       <NA>
##    4:       <NA>       <NA>       <NA>       <NA>       <NA>       <NA>
##    5:       <NA>       <NA>       <NA>       <NA>       <NA>       <NA>
##   ---                                                                  
## 3193:       <NA>       <NA>       <NA>       <NA>       <NA>       <NA>
## 3194:       <NA>       <NA>       <NA>       <NA>       <NA>       <NA>
## 3195:       <NA>       <NA>       <NA>       <NA>       <NA>       <NA>
## 3196:       <NA>       <NA>       <NA>       <NA>       <NA>       <NA>
## 3197:       <NA>       <NA>       <NA>       <NA>       <NA>       <NA>
##       EC017Q02NA EC018Q01NA EC018Q02NA EC018Q03NA EC018Q04NA EC019Q03NA
##    1:       <NA>       <NA>       <NA>       <NA>       <NA>       <NA>
##    2:       <NA>       <NA>       <NA>       <NA>       <NA>       <NA>
##    3:       <NA>       <NA>       <NA>       <NA>       <NA>       <NA>
##    4:       <NA>       <NA>       <NA>       <NA>       <NA>       <NA>
##    5:       <NA>       <NA>       <NA>       <NA>       <NA>       <NA>
##   ---                                                                  
## 3193:       <NA>       <NA>       <NA>       <NA>       <NA>       <NA>
## 3194:       <NA>       <NA>       <NA>       <NA>       <NA>       <NA>
## 3195:       <NA>       <NA>       <NA>       <NA>       <NA>       <NA>
## 3196:       <NA>       <NA>       <NA>       <NA>       <NA>       <NA>
## 3197:       <NA>       <NA>       <NA>       <NA>       <NA>       <NA>
##       EC019Q07NA EC019Q10NA EC019Q12NA EC019Q13NA EC019Q14NA EC020Q04NA
##    1:       <NA>       <NA>       <NA>       <NA>       <NA>       <NA>
##    2:       <NA>       <NA>       <NA>       <NA>       <NA>       <NA>
##    3:       <NA>       <NA>       <NA>       <NA>       <NA>       <NA>
##    4:       <NA>       <NA>       <NA>       <NA>       <NA>       <NA>
##    5:       <NA>       <NA>       <NA>       <NA>       <NA>       <NA>
##   ---                                                                  
## 3193:       <NA>       <NA>       <NA>       <NA>       <NA>       <NA>
## 3194:       <NA>       <NA>       <NA>       <NA>       <NA>       <NA>
## 3195:       <NA>       <NA>       <NA>       <NA>       <NA>       <NA>
## 3196:       <NA>       <NA>       <NA>       <NA>       <NA>       <NA>
## 3197:       <NA>       <NA>       <NA>       <NA>       <NA>       <NA>
##       EC020Q06NA EC020Q07NA EC020Q08NA EC020Q09NA EC020Q10NA EC020Q11NA
##    1:       <NA>       <NA>       <NA>       <NA>       <NA>       <NA>
##    2:       <NA>       <NA>       <NA>       <NA>       <NA>       <NA>
##    3:       <NA>       <NA>       <NA>       <NA>       <NA>       <NA>
##    4:       <NA>       <NA>       <NA>       <NA>       <NA>       <NA>
##    5:       <NA>       <NA>       <NA>       <NA>       <NA>       <NA>
##   ---                                                                  
## 3193:       <NA>       <NA>       <NA>       <NA>       <NA>       <NA>
## 3194:       <NA>       <NA>       <NA>       <NA>       <NA>       <NA>
## 3195:       <NA>       <NA>       <NA>       <NA>       <NA>       <NA>
## 3196:       <NA>       <NA>       <NA>       <NA>       <NA>       <NA>
## 3197:       <NA>       <NA>       <NA>       <NA>       <NA>       <NA>
##       EC020Q12NA EC021Q01NA EC021Q02NA EC021Q03NA EC021Q04NA EC021Q05NA
##    1:       <NA>       <NA>       <NA>       <NA>       <NA>       <NA>
##    2:       <NA>       <NA>       <NA>       <NA>       <NA>       <NA>
##    3:       <NA>       <NA>       <NA>       <NA>       <NA>       <NA>
##    4:       <NA>       <NA>       <NA>       <NA>       <NA>       <NA>
##    5:       <NA>       <NA>       <NA>       <NA>       <NA>       <NA>
##   ---                                                                  
## 3193:       <NA>       <NA>       <NA>       <NA>       <NA>       <NA>
## 3194:       <NA>       <NA>       <NA>       <NA>       <NA>       <NA>
## 3195:       <NA>       <NA>       <NA>       <NA>       <NA>       <NA>
## 3196:       <NA>       <NA>       <NA>       <NA>       <NA>       <NA>
## 3197:       <NA>       <NA>       <NA>       <NA>       <NA>       <NA>
##       EC022Q01NA EC022Q02NA EC022Q03NA EC022Q04NA EC022Q05NA EC022Q06NA
##    1:       <NA>       <NA>       <NA>       <NA>       <NA>       <NA>
##    2:       <NA>       <NA>       <NA>       <NA>       <NA>       <NA>
##    3:       <NA>       <NA>       <NA>       <NA>       <NA>       <NA>
##    4:       <NA>       <NA>       <NA>       <NA>       <NA>       <NA>
##    5:       <NA>       <NA>       <NA>       <NA>       <NA>       <NA>
##   ---                                                                  
## 3193:       <NA>       <NA>       <NA>       <NA>       <NA>       <NA>
## 3194:       <NA>       <NA>       <NA>       <NA>       <NA>       <NA>
## 3195:       <NA>       <NA>       <NA>       <NA>       <NA>       <NA>
## 3196:       <NA>       <NA>       <NA>       <NA>       <NA>       <NA>
## 3197:       <NA>       <NA>       <NA>       <NA>       <NA>       <NA>
##       EC022Q07NA EC022Q08NA EC022Q09NA EC022Q10NA EC022Q11NA EC022Q12NA
##    1:       <NA>       <NA>       <NA>       <NA>       <NA>       <NA>
##    2:       <NA>       <NA>       <NA>       <NA>       <NA>       <NA>
##    3:       <NA>       <NA>       <NA>       <NA>       <NA>       <NA>
##    4:       <NA>       <NA>       <NA>       <NA>       <NA>       <NA>
##    5:       <NA>       <NA>       <NA>       <NA>       <NA>       <NA>
##   ---                                                                  
## 3193:       <NA>       <NA>       <NA>       <NA>       <NA>       <NA>
## 3194:       <NA>       <NA>       <NA>       <NA>       <NA>       <NA>
## 3195:       <NA>       <NA>       <NA>       <NA>       <NA>       <NA>
## 3196:       <NA>       <NA>       <NA>       <NA>       <NA>       <NA>
## 3197:       <NA>       <NA>       <NA>       <NA>       <NA>       <NA>
##       EC023Q01NA EC023Q02NA EC023Q03NA EC023Q04NA EC023Q05NA EC023Q06NA
##    1:       <NA>       <NA>       <NA>       <NA>       <NA>       <NA>
##    2:       <NA>       <NA>       <NA>       <NA>       <NA>       <NA>
##    3:       <NA>       <NA>       <NA>       <NA>       <NA>       <NA>
##    4:       <NA>       <NA>       <NA>       <NA>       <NA>       <NA>
##    5:       <NA>       <NA>       <NA>       <NA>       <NA>       <NA>
##   ---                                                                  
## 3193:       <NA>       <NA>       <NA>       <NA>       <NA>       <NA>
## 3194:       <NA>       <NA>       <NA>       <NA>       <NA>       <NA>
## 3195:       <NA>       <NA>       <NA>       <NA>       <NA>       <NA>
## 3196:       <NA>       <NA>       <NA>       <NA>       <NA>       <NA>
## 3197:       <NA>       <NA>       <NA>       <NA>       <NA>       <NA>
##       EC023Q07NA EC023Q08NA EC023Q09NA EC023Q10NA EC023Q11NA EC023Q12NA
##    1:       <NA>       <NA>       <NA>       <NA>       <NA>       <NA>
##    2:       <NA>       <NA>       <NA>       <NA>       <NA>       <NA>
##    3:       <NA>       <NA>       <NA>       <NA>       <NA>       <NA>
##    4:       <NA>       <NA>       <NA>       <NA>       <NA>       <NA>
##    5:       <NA>       <NA>       <NA>       <NA>       <NA>       <NA>
##   ---                                                                  
## 3193:       <NA>       <NA>       <NA>       <NA>       <NA>       <NA>
## 3194:       <NA>       <NA>       <NA>       <NA>       <NA>       <NA>
## 3195:       <NA>       <NA>       <NA>       <NA>       <NA>       <NA>
## 3196:       <NA>       <NA>       <NA>       <NA>       <NA>       <NA>
## 3197:       <NA>       <NA>       <NA>       <NA>       <NA>       <NA>
##       EC023Q13NA EC024Q01NA EC024Q02NA EC024Q03NA EC024Q04NA EC024Q05NA
##    1:       <NA>       <NA>       <NA>       <NA>       <NA>       <NA>
##    2:       <NA>       <NA>       <NA>       <NA>       <NA>       <NA>
##    3:       <NA>       <NA>       <NA>       <NA>       <NA>       <NA>
##    4:       <NA>       <NA>       <NA>       <NA>       <NA>       <NA>
##    5:       <NA>       <NA>       <NA>       <NA>       <NA>       <NA>
##   ---                                                                  
## 3193:       <NA>       <NA>       <NA>       <NA>       <NA>       <NA>
## 3194:       <NA>       <NA>       <NA>       <NA>       <NA>       <NA>
## 3195:       <NA>       <NA>       <NA>       <NA>       <NA>       <NA>
## 3196:       <NA>       <NA>       <NA>       <NA>       <NA>       <NA>
## 3197:       <NA>       <NA>       <NA>       <NA>       <NA>       <NA>
##       EC024Q06NA EC024Q07NA EC024Q08NA EC026Q01NA EC026Q02NA EC027Q01NA
##    1:       <NA>       <NA>       <NA>       <NA>       <NA>       <NA>
##    2:       <NA>       <NA>       <NA>       <NA>       <NA>       <NA>
##    3:       <NA>       <NA>       <NA>       <NA>       <NA>       <NA>
##    4:       <NA>       <NA>       <NA>       <NA>       <NA>       <NA>
##    5:       <NA>       <NA>       <NA>       <NA>       <NA>       <NA>
##   ---                                                                  
## 3193:       <NA>       <NA>       <NA>       <NA>       <NA>       <NA>
## 3194:       <NA>       <NA>       <NA>       <NA>       <NA>       <NA>
## 3195:       <NA>       <NA>       <NA>       <NA>       <NA>       <NA>
## 3196:       <NA>       <NA>       <NA>       <NA>       <NA>       <NA>
## 3197:       <NA>       <NA>       <NA>       <NA>       <NA>       <NA>
##       EC027Q02NA EC027Q03NA EC027Q04NA EC028Q01NA EC028Q02NA EC028Q03NA
##    1:       <NA>       <NA>       <NA>       <NA>       <NA>       <NA>
##    2:       <NA>       <NA>       <NA>       <NA>       <NA>       <NA>
##    3:       <NA>       <NA>       <NA>       <NA>       <NA>       <NA>
##    4:       <NA>       <NA>       <NA>       <NA>       <NA>       <NA>
##    5:       <NA>       <NA>       <NA>       <NA>       <NA>       <NA>
##   ---                                                                  
## 3193:       <NA>       <NA>       <NA>       <NA>       <NA>       <NA>
## 3194:       <NA>       <NA>       <NA>       <NA>       <NA>       <NA>
## 3195:       <NA>       <NA>       <NA>       <NA>       <NA>       <NA>
## 3196:       <NA>       <NA>       <NA>       <NA>       <NA>       <NA>
## 3197:       <NA>       <NA>       <NA>       <NA>       <NA>       <NA>
##       EC029Q01NA EC030Q01NA EC030Q02NA EC030Q03NA EC030Q04NA EC030Q05NA
##    1:         NA         No        Yes        Yes         No         No
##    2:         NA        Yes        Yes        Yes        Yes        Yes
##    3:         NA        Yes         No         No         No        Yes
##    4:         NA        Yes         No        Yes         No         No
##    5:         NA        Yes         No         No         No         No
##   ---                                                                  
## 3193:         NA       <NA>       <NA>       <NA>       <NA>       <NA>
## 3194:         NA        Yes        Yes         No         No        Yes
## 3195:         NA         No         No         No         No         No
## 3196:         NA        Yes        Yes        Yes         No         No
## 3197:         NA        Yes         No        Yes         No         No
##       EC030Q06NA EC030Q07NA                                          EC031Q01TA
##    1:         No        Yes No, I attended all of <ISCED 1> at the same school.
##    2:        Yes        Yes No, I attended all of <ISCED 1> at the same school.
##    3:        Yes         No No, I attended all of <ISCED 1> at the same school.
##    4:        Yes        Yes No, I attended all of <ISCED 1> at the same school.
##    5:         No        Yes No, I attended all of <ISCED 1> at the same school.
##   ---                                                                          
## 3193:       <NA>       <NA>                                                <NA>
## 3194:         No         No               Yes, I changed schools twice or more.
## 3195:        Yes         No No, I attended all of <ISCED 1> at the same school.
## 3196:        Yes         No                        Yes, I changed schools once.
## 3197:        Yes         No No, I attended all of <ISCED 1> at the same school.
##                                                EC032Q01TA EC033Q01NA
##    1: No, I attended all of <ISCED 2> at the same school.       <NA>
##    2:                        Yes, I changed schools once.       <NA>
##    3: No, I attended all of <ISCED 2> at the same school.       <NA>
##    4: No, I attended all of <ISCED 2> at the same school.       <NA>
##    5: No, I attended all of <ISCED 2> at the same school.       <NA>
##   ---                                                               
## 3193:                                                <NA>       <NA>
## 3194: No, I attended all of <ISCED 2> at the same school.       <NA>
## 3195:                        Yes, I changed schools once.       <NA>
## 3196:                        Yes, I changed schools once.       <NA>
## 3197: No, I attended all of <ISCED 2> at the same school.       <NA>
##        PA001Q01TA  PA001Q02TA  PA001Q03TA PA002Q01TA PA002Q02TA PA002Q03TA
##    1:        <NA>        <NA>        <NA>       <NA>       <NA>       <NA>
##    2:     Checked Not checked Not checked      Never      Never      Never
##    3:     Checked Not checked Not checked      Never      Never      Never
##    4:        <NA>        <NA>        <NA>       <NA>       <NA>       <NA>
##    5:     Checked Not checked Not checked  Sometimes      Never  Sometimes
##   ---                                                                     
## 3193:     Checked Not checked Not checked  Sometimes  Sometimes      Never
## 3194:     Checked Not checked Not checked  Sometimes      Never      Never
## 3195:     Checked Not checked Not checked  Sometimes  Sometimes      Never
## 3196: Not checked Not checked Not checked  Sometimes  Sometimes      Never
## 3197:        <NA>        <NA>        <NA>       <NA>       <NA>       <NA>
##       PA002Q04TA PA002Q05TA PA002Q06NA PA002Q07NA PA002Q08NA PA002Q09NA
##    1:       <NA>       <NA>       <NA>       <NA>       <NA>       <NA>
##    2:      Never      Never      Never      Never      Never      Never
##    3:      Never      Never Very Often      Never      Never      Never
##    4:       <NA>       <NA>       <NA>       <NA>       <NA>       <NA>
##    5:  Sometimes      Never Very Often  Sometimes      Never  Sometimes
##   ---                                                                  
## 3193:      Never      Never  Sometimes      Never      Never  Sometimes
## 3194:  Sometimes      Never  Sometimes      Never  Sometimes  Sometimes
## 3195:  Sometimes      Never  Sometimes      Never  Sometimes  Sometimes
## 3196:  Sometimes      Never      Never      Never      Never  Sometimes
## 3197:       <NA>       <NA>       <NA>       <NA>       <NA>       <NA>
##       PA002Q10NA                    PA003Q01TA                    PA003Q02TA
##    1:       <NA>                          <NA>                          <NA>
##    2:      Never          Once or twice a week          Once or twice a week
##    3:      Never          Once or twice a week Every day or almost every day
##    4:       <NA>                          <NA>                          <NA>
##    5:  Sometimes          Once or twice a week Every day or almost every day
##   ---                                                                       
## 3193:  Sometimes         Once or twice a month Every day or almost every day
## 3194:  Sometimes          Once or twice a week          Once or twice a week
## 3195:  Sometimes Every day or almost every day Every day or almost every day
## 3196:      Never Every day or almost every day Every day or almost every day
## 3197:       <NA>                          <NA>                          <NA>
##                          PA003Q03TA            PA003Q04NA            PA003Q05NA
##    1:                          <NA>                  <NA>                  <NA>
##    2: Every day or almost every day  Never or hardly ever  Once or twice a week
##    3: Every day or almost every day                  <NA>  Once or twice a week
##    4:                          <NA>                  <NA>                  <NA>
##    5: Every day or almost every day  Once or twice a year  Once or twice a week
##   ---                                                                          
## 3193: Every day or almost every day Once or twice a month Once or twice a month
## 3194: Every day or almost every day Once or twice a month  Once or twice a year
## 3195: Every day or almost every day Once or twice a month Once or twice a month
## 3196: Every day or almost every day  Once or twice a week  Once or twice a week
## 3197:                          <NA>                  <NA>                  <NA>
##                  PA003Q06NA            PA003Q07NA            PA003Q08NA
##    1:                  <NA>                  <NA>                  <NA>
##    2:  Never or hardly ever  Never or hardly ever  Never or hardly ever
##    3:  Never or hardly ever Once or twice a month  Once or twice a year
##    4:                  <NA>                  <NA>                  <NA>
##    5:  Never or hardly ever  Once or twice a year Once or twice a month
##   ---                                                                  
## 3193:  Once or twice a year Once or twice a month  Never or hardly ever
## 3194:  Once or twice a year  Once or twice a year  Once or twice a year
## 3195:  Never or hardly ever Once or twice a month  Never or hardly ever
## 3196: Once or twice a month Once or twice a month Once or twice a month
## 3197:                  <NA>                  <NA>                  <NA>
##           PA004Q01NA     PA004Q02NA     PA004Q03NA     PA004Q04NA
##    1:           <NA>           <NA>           <NA>           <NA>
##    2:          Agree          Agree          Agree Strongly agree
##    3: Strongly agree Strongly agree Strongly agree Strongly agree
##    4:           <NA>           <NA>           <NA>           <NA>
##    5: Strongly agree Strongly agree Strongly agree Strongly agree
##   ---                                                            
## 3193:          Agree Strongly agree Strongly agree Strongly agree
## 3194: Strongly agree Strongly agree Strongly agree Strongly agree
## 3195:       Disagree          Agree          Agree          Agree
## 3196: Strongly agree Strongly agree Strongly agree Strongly agree
## 3197:           <NA>           <NA>           <NA>           <NA>
##                                                                                                           PA005Q01TA
##    1:                                                                                                           <NA>
##    2:          There is one other school in this area that competes with the school my child is currently attending.
##    3:          There is one other school in this area that competes with the school my child is currently attending.
##    4:                                                                                                           <NA>
##    5:          There are no other schools in this area that compete with the school my child is currently attending.
##   ---                                                                                                               
## 3193: There are two or more other schools in this area that compete with the school my child is currently attending.
## 3194: There are two or more other schools in this area that compete with the school my child is currently attending.
## 3195:          There are no other schools in this area that compete with the school my child is currently attending.
## 3196:          There are no other schools in this area that compete with the school my child is currently attending.
## 3197:                                                                                                           <NA>
##               PA006Q01TA     PA006Q02TA         PA006Q03TA         PA006Q04TA
##    1:               <NA>           <NA>               <NA>               <NA>
##    2:      Not important      Important          Important      Not important
##    3:          Important Very important Somewhat important Somewhat important
##    4:               <NA>           <NA>               <NA>               <NA>
##    5:     Very important Very important          Important      Not important
##   ---                                                                        
## 3193:          Important      Important          Important Somewhat important
## 3194:     Very important Very important     Very important      Not important
## 3195: Somewhat important      Important Somewhat important      Not important
## 3196:     Very important Very important     Very important      Not important
## 3197:               <NA>           <NA>               <NA>               <NA>
##               PA006Q05TA         PA006Q06TA         PA006Q07TA
##    1:               <NA>               <NA>               <NA>
##    2:      Not important Somewhat important          Important
##    3:      Not important      Not important Somewhat important
##    4:               <NA>               <NA>               <NA>
##    5:      Not important      Not important     Very important
##   ---                                                         
## 3193: Somewhat important      Not important Somewhat important
## 3194: Somewhat important      Not important      Not important
## 3195:      Not important      Not important      Not important
## 3196:               <NA>      Not important     Very important
## 3197:               <NA>               <NA>               <NA>
##               PA006Q08TA     PA006Q09TA         PA006Q10TA         PA006Q11TA
##    1:               <NA>           <NA>               <NA>               <NA>
##    2: Somewhat important      Important          Important          Important
##    3:      Not important      Important     Very important     Very important
##    4:               <NA>           <NA>               <NA>               <NA>
##    5:     Very important Very important     Very important     Very important
##   ---                                                                        
## 3193:          Important Very important Somewhat important Somewhat important
## 3194:      Not important Very important     Very important     Very important
## 3195:      Not important      Important          Important          Important
## 3196:          Important Very important          Important     Very important
## 3197:               <NA>           <NA>               <NA>               <NA>
##       PA007Q01TA        PA007Q02TA        PA007Q03TA        PA007Q04TA
##    1:       <NA>              <NA>              <NA>              <NA>
##    2:      Agree    Strongly agree             Agree             Agree
##    3:      Agree             Agree             Agree             Agree
##    4:       <NA>              <NA>              <NA>              <NA>
##    5:      Agree    Strongly agree          Disagree             Agree
##   ---                                                                 
## 3193:   Disagree          Disagree          Disagree          Disagree
## 3194:   Disagree Strongly disagree Strongly disagree Strongly disagree
## 3195:   Disagree          Disagree          Disagree          Disagree
## 3196:      Agree             Agree          Disagree             Agree
## 3197:       <NA>              <NA>              <NA>              <NA>
##              PA007Q05TA        PA007Q06TA        PA007Q07TA        PA007Q09NA
##    1:              <NA>              <NA>              <NA>              <NA>
##    2:             Agree             Agree             Agree             Agree
##    3:             Agree             Agree    Strongly agree             Agree
##    4:              <NA>              <NA>              <NA>              <NA>
##    5:             Agree             Agree             Agree             Agree
##   ---                                                                        
## 3193:          Disagree          Disagree          Disagree          Disagree
## 3194: Strongly disagree Strongly disagree Strongly disagree Strongly disagree
## 3195:          Disagree Strongly disagree          Disagree          Disagree
## 3196:    Strongly agree             Agree             Agree          Disagree
## 3197:              <NA>              <NA>              <NA>              <NA>
##              PA007Q11NA        PA007Q12NA        PA007Q13NA        PA007Q14NA
##    1:              <NA>              <NA>              <NA>              <NA>
##    2:             Agree             Agree          Disagree          Disagree
##    3:             Agree          Disagree          Disagree          Disagree
##    4:              <NA>              <NA>              <NA>              <NA>
##    5:             Agree          Disagree Strongly disagree Strongly disagree
##   ---                                                                        
## 3193: Strongly disagree          Disagree Strongly disagree          Disagree
## 3194: Strongly disagree Strongly disagree Strongly disagree Strongly disagree
## 3195:          Disagree             Agree          Disagree          Disagree
## 3196:             Agree          Disagree          Disagree Strongly disagree
## 3197:              <NA>              <NA>              <NA>              <NA>
##              PA007Q15NA PA008Q01TA PA008Q02TA PA008Q03TA PA008Q04TA PA008Q05TA
##    1:              <NA>       <NA>       <NA>       <NA>       <NA>       <NA>
##    2:          Disagree        Yes         No        Yes         No         No
##    3:             Agree         No         No         No         No         No
##    4:              <NA>       <NA>       <NA>       <NA>       <NA>       <NA>
##    5:          Disagree       <NA>       <NA>         No        Yes        Yes
##   ---                                                                         
## 3193:             Agree        Yes        Yes         No         No         No
## 3194: Strongly disagree        Yes        Yes       <NA>        Yes         No
## 3195:          Disagree         No         No         No         No         No
## 3196:          Disagree        Yes        Yes         No        Yes         No
## 3197:              <NA>       <NA>       <NA>       <NA>       <NA>       <NA>
##                    PA008Q06NA PA008Q07NA PA008Q08NA PA008Q09NA PA008Q10NA
##    1:                    <NA>       <NA>       <NA>       <NA>       <NA>
##    2:                      No         No        Yes         No         No
##    3:                      No         No        Yes         No         No
##    4:                    <NA>       <NA>       <NA>       <NA>       <NA>
##    5:                      No         No        Yes         No        Yes
##   ---                                                                    
## 3193:                     Yes         No        Yes         No        Yes
## 3194:                      No         No        Yes         No         No
## 3195:                      No         No        Yes         No         No
## 3196: Not supported by school        Yes        Yes        Yes        Yes
## 3197:                    <NA>       <NA>       <NA>       <NA>       <NA>
##       PA009Q01NA PA009Q02NA PA009Q03NA PA009Q04NA PA009Q05NA PA009Q06NA
##    1:       <NA>       <NA>       <NA>       <NA>       <NA>       <NA>
##    2:         No         No         No         No         No         No
##    3:         No         No         No         No         No         No
##    4:       <NA>       <NA>       <NA>       <NA>       <NA>       <NA>
##    5:         No         No         No         No         No         No
##   ---                                                                  
## 3193:         No         No         No         No         No         No
## 3194:        Yes        Yes        Yes         No         No         No
## 3195:        Yes        Yes         No         No         No         No
## 3196:         No        Yes        Yes         No         No         No
## 3197:       <NA>       <NA>       <NA>       <NA>       <NA>       <NA>
##       PA009Q08NA PA009Q09NA PA009Q10NA PA009Q11NA PA011Q01NA PA011Q02NA
##    1:       <NA>       <NA>       <NA>       <NA>       <NA>       <NA>
##    2:         No         No         No         No  6 or more  6 or more
##    3:         No         No         No         No  6 or more  6 or more
##    4:       <NA>       <NA>       <NA>       <NA>       <NA>       <NA>
##    5:         No         No         No         No  6 or more  6 or more
##   ---                                                                  
## 3193:         No         No         No         No  6 or more  6 or more
## 3194:         No         No         No         No  6 or more        1-2
## 3195:         No        Yes         No         No  6 or more  6 or more
## 3196:         No         No         No         No        3-5        3-5
## 3197:       <NA>       <NA>       <NA>       <NA>       <NA>       <NA>
##       PA011Q03NA PA014Q01NA PA018Q01NA PA018Q02NA PA018Q03NA  PA019Q01NA
##    1:       <NA>         NA       <NA>       <NA>       <NA>        <NA>
##    2:        3-5          6         No         No        Yes        <NA>
##    3:        3-5          6         No         No        Yes        <NA>
##    4:       <NA>         NA       <NA>       <NA>       <NA>        <NA>
##    5:        3-5          6       <NA>         No        Yes Not checked
##   ---                                                                   
## 3193:        1-2          6        Yes         No         No Not checked
## 3194:        1-2          6         No         No         No        <NA>
## 3195:        1-2          6        Yes       <NA>       <NA> Not checked
## 3196:        1-2          6        Yes         No         No Not checked
## 3197:       <NA>         NA       <NA>       <NA>       <NA>        <NA>
##        PA019Q02NA  PA019Q03NA  PA019Q04NA  PA019Q05NA  PA019Q06NA  PA019Q07NA
##    1:        <NA>        <NA>        <NA>        <NA>        <NA>        <NA>
##    2:        <NA>        <NA>        <NA>        <NA>        <NA>        <NA>
##    3:        <NA>        <NA>        <NA>        <NA>        <NA>        <NA>
##    4:        <NA>        <NA>        <NA>        <NA>        <NA>        <NA>
##    5: Not checked Not checked Not checked Not checked Not checked Not checked
##   ---                                                                        
## 3193: Not checked Not checked     Checked Not checked Not checked Not checked
## 3194:        <NA>        <NA>        <NA>        <NA>        <NA>        <NA>
## 3195: Not checked Not checked     Checked Not checked Not checked Not checked
## 3196: Not checked Not checked     Checked Not checked Not checked Not checked
## 3197:        <NA>        <NA>        <NA>        <NA>        <NA>        <NA>
##        PA019Q08NA  PA020Q01NA  PA020Q02NA  PA020Q03NA  PA020Q04NA  PA021Q01NA
##    1:        <NA>        <NA>        <NA>        <NA>        <NA>        <NA>
##    2:        <NA>        <NA>        <NA>        <NA>        <NA>        <NA>
##    3:        <NA>        <NA>        <NA>        <NA>        <NA>        <NA>
##    4:        <NA>        <NA>        <NA>        <NA>        <NA>        <NA>
##    5: Not checked Not checked Not checked Not checked Not checked Not checked
##   ---                                                                        
## 3193: Not checked Not checked Not checked Not checked     Checked Not checked
## 3194:        <NA>        <NA>        <NA>        <NA>        <NA>        <NA>
## 3195: Not checked Not checked     Checked Not checked Not checked     Checked
## 3196: Not checked Not checked Not checked Not checked     Checked     Checked
## 3197:        <NA>        <NA>        <NA>        <NA>        <NA>        <NA>
##        PA021Q02NA  PA021Q03NA  PA021Q04NA
##    1:        <NA>        <NA>        <NA>
##    2:        <NA>        <NA>        <NA>
##    3:        <NA>        <NA>        <NA>
##    4:        <NA>        <NA>        <NA>
##    5: Not checked Not checked Not checked
##   ---                                    
## 3193: Not checked     Checked Not checked
## 3194:        <NA>        <NA>        <NA>
## 3195: Not checked     Checked Not checked
## 3196: Not checked Not checked Not checked
## 3197:        <NA>        <NA>        <NA>
##                                                                                  PA022Q01NA
##    1:                                                                                  <NA>
##    2:                                                                                  <NA>
##    3:                                                                                  <NA>
##    4:                                                                                  <NA>
##    5:                                                                                  <NA>
##   ---                                                                                      
## 3193: We\\I wanted additional learning stimulation for the child (e. g., social, academic).
## 3194:                                                                                  <NA>
## 3195: We\\I wanted additional learning stimulation for the child (e. g., social, academic).
## 3196: We\\I wanted additional learning stimulation for the child (e. g., social, academic).
## 3197:                                                                                  <NA>
##        PA023Q01NA  PA023Q02NA  PA023Q03NA PA023Q04NA  PA023Q05NA  PA023Q06NA
##    1:        <NA>        <NA>        <NA>       <NA>        <NA>        <NA>
##    2:        <NA>        <NA>        <NA>       <NA>        <NA>        <NA>
##    3:        <NA>        <NA>        <NA>       <NA>        <NA>        <NA>
##    4:        <NA>        <NA>        <NA>       <NA>        <NA>        <NA>
##    5:        <NA>        <NA>        <NA>       <NA>        <NA>        <NA>
##   ---                                                                       
## 3193:        <NA>        <NA>        <NA>       <NA>        <NA>        <NA>
## 3194:        <NA>        <NA>        <NA>       <NA>        <NA>        <NA>
## 3195: Not checked Not checked Not checked    Checked Not checked Not checked
## 3196:        <NA>        <NA>        <NA>       <NA>        <NA>        <NA>
## 3197:        <NA>        <NA>        <NA>       <NA>        <NA>        <NA>
##        PA023Q07NA  PA023Q08NA
##    1:        <NA>        <NA>
##    2:        <NA>        <NA>
##    3:        <NA>        <NA>
##    4:        <NA>        <NA>
##    5:        <NA>        <NA>
##   ---                        
## 3193:        <NA>        <NA>
## 3194:        <NA>        <NA>
## 3195: Not checked Not checked
## 3196:        <NA>        <NA>
## 3197:        <NA>        <NA>
##                                                                                  PA026Q01NA
##    1:                                                                                  <NA>
##    2:                                                                                  <NA>
##    3:                                                                                  <NA>
##    4:                                                                                  <NA>
##    5:                                                                                  <NA>
##   ---                                                                                      
## 3193:                                                                                  <NA>
## 3194:                                                                                  <NA>
## 3195: We\\I wanted additional learning stimulation for the child (e. g., social, academic).
## 3196:                                                                                  <NA>
## 3197:                                                                                  <NA>
##        PA027Q01NA  PA027Q02NA  PA027Q03NA  PA027Q04NA  PA027Q05NA  PA027Q06NA
##    1:        <NA>        <NA>        <NA>        <NA>        <NA>        <NA>
##    2: Not checked Not checked Not checked     Checked Not checked Not checked
##    3: Not checked Not checked Not checked Not checked Not checked Not checked
##    4:        <NA>        <NA>        <NA>        <NA>        <NA>        <NA>
##    5: Not checked Not checked Not checked     Checked Not checked Not checked
##   ---                                                                        
## 3193:        <NA>        <NA>        <NA>        <NA>        <NA>        <NA>
## 3194:        <NA>        <NA>        <NA>        <NA>        <NA>        <NA>
## 3195: Not checked Not checked Not checked Not checked Not checked     Checked
## 3196:        <NA>        <NA>        <NA>        <NA>        <NA>        <NA>
## 3197:        <NA>        <NA>        <NA>        <NA>        <NA>        <NA>
##        PA027Q07NA  PA027Q08NA
##    1:        <NA>        <NA>
##    2: Not checked Not checked
##    3: Not checked Not checked
##    4:        <NA>        <NA>
##    5: Not checked Not checked
##   ---                        
## 3193:        <NA>        <NA>
## 3194:        <NA>        <NA>
## 3195: Not checked Not checked
## 3196:        <NA>        <NA>
## 3197:        <NA>        <NA>
##                                                                   PA028Q01NA
##    1:                                                                   <NA>
##    2: Private management and mainly public funding (e.g. <national example>)
##    3:  Public management and mainly public funding (e.g. <national example>)
##    4:                                                                   <NA>
##    5:  Public management and mainly public funding (e.g. <national example>)
##   ---                                                                       
## 3193:                                                                   <NA>
## 3194:                                                                   <NA>
## 3195: Private management and mainly public funding (e.g. <national example>)
## 3196:                                                                   <NA>
## 3197:                                                                   <NA>
##                    PA029Q01NA
##    1:                    <NA>
##    2:    11-20 hours per week
##    3:    21-30 hours per week
##    4:                    <NA>
##    5:    21-30 hours per week
##   ---                        
## 3193:                    <NA>
## 3194:                    <NA>
## 3195: up to 10 hours per week
## 3196:                    <NA>
## 3197:                    <NA>
##                                                                PA030Q01NA
##    1:                                                                <NA>
##    2: Most other children attended a <pre-primary education arrangement>.
##    3:                                                                <NA>
##    4:                                                                <NA>
##    5: Most other children attended a <pre-primary education arrangement>.
##   ---                                                                    
## 3193:                                                                <NA>
## 3194:                                                                <NA>
## 3195:                                           Attendance was mandatory.
## 3196:                                                                <NA>
## 3197:                                                                <NA>
##       PA032Q01TA PA032Q02TA PA032Q03TA PA032Q04TA PA032Q05TA     PA033Q02TA
##    1:       <NA>       <NA>       <NA>       <NA>       <NA>           <NA>
##    2:         No         No         No         No         No          Agree
##    3:        Yes         No         No         No         No          Agree
##    4:       <NA>       <NA>       <NA>       <NA>       <NA>           <NA>
##    5:         No         No         No         No         No          Agree
##   ---                                                                      
## 3193:        Yes        Yes         No         No         No Strongly agree
## 3194:         No         No         No         No         No Strongly agree
## 3195:         No         No         No         No         No          Agree
## 3196:         No         No         No         No         No Strongly agree
## 3197:       <NA>       <NA>       <NA>       <NA>       <NA>           <NA>
##           PA033Q06TA     PA033Q07TA     PA033Q08TA     PA033Q09TA
##    1:           <NA>           <NA>           <NA>           <NA>
##    2:          Agree       Disagree       Disagree          Agree
##    3:          Agree          Agree          Agree          Agree
##    4:           <NA>           <NA>           <NA>           <NA>
##    5:          Agree       Disagree          Agree       Disagree
##   ---                                                            
## 3193:          Agree          Agree          Agree       Disagree
## 3194: Strongly agree Strongly agree Strongly agree Strongly agree
## 3195: Strongly agree       Disagree          Agree       Disagree
## 3196: Strongly agree Strongly agree Strongly agree Strongly agree
## 3197:           <NA>           <NA>           <NA>           <NA>
##                                                                           PA035Q01TA
##    1:                                                                           <NA>
##    2: This is a serious concern for other people in my country but not me personally
##    3:                  This is a serious concern for me personally as well as others
##    4:                                                                           <NA>
##    5:                  This is a serious concern for me personally as well as others
##   ---                                                                               
## 3193:                  This is a serious concern for me personally as well as others
## 3194: This is a serious concern for other people in my country but not me personally
## 3195:                   This is a serious concern only for people in other countries
## 3196:                  This is a serious concern for me personally as well as others
## 3197:                                                                           <NA>
##                                                                           PA035Q03TA
##    1:                                                                           <NA>
##    2: This is a serious concern for other people in my country but not me personally
##    3:                                                                           <NA>
##    4:                                                                           <NA>
##    5:                   This is a serious concern only for people in other countries
##   ---                                                                               
## 3193:                  This is a serious concern for me personally as well as others
## 3194: This is a serious concern for other people in my country but not me personally
## 3195: This is a serious concern for other people in my country but not me personally
## 3196:                  This is a serious concern for me personally as well as others
## 3197:                                                                           <NA>
##                                                                           PA035Q04TA
##    1:                                                                           <NA>
##    2: This is a serious concern for other people in my country but not me personally
##    3:                  This is a serious concern for me personally as well as others
##    4:                                                                           <NA>
##    5:                  This is a serious concern for me personally as well as others
##   ---                                                                               
## 3193:                  This is a serious concern for me personally as well as others
## 3194: This is a serious concern for other people in my country but not me personally
## 3195:                   This is a serious concern only for people in other countries
## 3196:                  This is a serious concern for me personally as well as others
## 3197:                                                                           <NA>
##                                                                           PA035Q05TA
##    1:                                                                           <NA>
##    2:                  This is a serious concern for me personally as well as others
##    3:                  This is a serious concern for me personally as well as others
##    4:                                                                           <NA>
##    5:                   This is a serious concern only for people in other countries
##   ---                                                                               
## 3193:                  This is a serious concern for me personally as well as others
## 3194: This is a serious concern for other people in my country but not me personally
## 3195:                  This is a serious concern for me personally as well as others
## 3196:                  This is a serious concern for me personally as well as others
## 3197:                                                                           <NA>
##                                                                           PA035Q06TA
##    1:                                                                           <NA>
##    2:                  This is a serious concern for me personally as well as others
##    3:                  This is a serious concern for me personally as well as others
##    4:                                                                           <NA>
##    5:                  This is a serious concern for me personally as well as others
##   ---                                                                               
## 3193:                  This is a serious concern for me personally as well as others
## 3194: This is a serious concern for other people in my country but not me personally
## 3195:                  This is a serious concern for me personally as well as others
## 3196:                  This is a serious concern for me personally as well as others
## 3197:                                                                           <NA>
##                                                                           PA035Q07NA
##    1:                                                                           <NA>
##    2:                  This is a serious concern for me personally as well as others
##    3:                  This is a serious concern for me personally as well as others
##    4:                                                                           <NA>
##    5:                                       This is not a serious concern for anyone
##   ---                                                                               
## 3193:                  This is a serious concern for me personally as well as others
## 3194: This is a serious concern for other people in my country but not me personally
## 3195:                  This is a serious concern for me personally as well as others
## 3196:                  This is a serious concern for me personally as well as others
## 3197:                                                                           <NA>
##                                                                           PA035Q08NA
##    1:                                                                           <NA>
##    2: This is a serious concern for other people in my country but not me personally
##    3:                  This is a serious concern for me personally as well as others
##    4:                                                                           <NA>
##    5: This is a serious concern for other people in my country but not me personally
##   ---                                                                               
## 3193:                  This is a serious concern for me personally as well as others
## 3194: This is a serious concern for other people in my country but not me personally
## 3195:                  This is a serious concern for me personally as well as others
## 3196:                  This is a serious concern for me personally as well as others
## 3197:                                                                           <NA>
##                PA036Q01TA          PA036Q03TA          PA036Q04TA
##    1:                <NA>                <NA>                <NA>
##    2: Stay about the same           Get worse Stay about the same
##    3: Stay about the same Stay about the same           Get worse
##    4:                <NA>                <NA>                <NA>
##    5:             Improve Stay about the same Stay about the same
##   ---                                                            
## 3193:           Get worse           Get worse           Get worse
## 3194:           Get worse           Get worse           Get worse
## 3195: Stay about the same           Get worse Stay about the same
## 3196:           Get worse           Get worse           Get worse
## 3197:                <NA>                <NA>                <NA>
##                PA036Q05TA          PA036Q06TA          PA036Q07NA
##    1:                <NA>                <NA>                <NA>
##    2: Stay about the same Stay about the same           Get worse
##    3:           Get worse           Get worse           Get worse
##    4:                <NA>                <NA>                <NA>
##    5:           Get worse           Get worse Stay about the same
##   ---                                                            
## 3193:           Get worse           Get worse           Get worse
## 3194:           Get worse           Get worse           Get worse
## 3195:           Get worse Stay about the same           Get worse
## 3196:           Get worse           Get worse           Get worse
## 3197:                <NA>                <NA>                <NA>
##                PA036Q08NA      PA039Q01TA      PA039Q02TA      PA039Q03TA
##    1:                <NA>            <NA>            <NA>            <NA>
##    2: Stay about the same Country of test Country of test Country of test
##    3:           Get worse Country of test Country of test Country of test
##    4:                <NA>            <NA>            <NA>            <NA>
##    5: Stay about the same Country of test Country of test Country of test
##   ---                                                                    
## 3193:           Get worse Country of test Country of test Country of test
## 3194:           Get worse Country of test   Other country Country of test
## 3195:           Get worse Country of test Country of test Country of test
## 3196:           Get worse Country of test            <NA>            <NA>
## 3197:                <NA>            <NA>            <NA>            <NA>
##            PA039Q04TA      PA039Q05TA      PA039Q06TA
##    1:            <NA>            <NA>            <NA>
##    2: Country of test Country of test Country of test
##    3: Country of test Country of test Country of test
##    4:            <NA>            <NA>            <NA>
##    5: Country of test Country of test Country of test
##   ---                                                
## 3193: Country of test Country of test Country of test
## 3194: Country of test   Other country   Other country
## 3195: Country of test Country of test Country of test
## 3196:            <NA>            <NA>            <NA>
## 3197:            <NA>            <NA>            <NA>
##                          PA041Q01TA                          PA042Q01TA   AGE
##    1:                          <NA>                                <NA> 16.25
##    2:                          <NA>                                <NA> 15.50
##    3:                       Nothing                                <NA> 15.42
##    4:                          <NA>                                <NA> 15.83
##    5: <$Y or more but less than $Z>                                <NA> 16.08
##   ---                                                                        
## 3193: <$W or more but less than $X>                                <NA> 16.08
## 3194: <$W or more but less than $X>  < $C > or more but less than < $D> 15.92
## 3195: <$W or more but less than $X> < $A > or more but less than < $B > 15.83
## 3196: <$X or more but less than $Y>                                <NA> 16.08
## 3197:                          <NA>                                <NA> 16.17
##                                                                                                                  PROGN
##    1: Germany: Lower secondary, access to upper secondary; academic education (exclusively students of the same track)
##    2: Germany: Lower secondary, access to upper secondary; academic education (exclusively students of the same track)
##    3: Germany: Lower secondary, access to upper secondary; academic education (exclusively students of the same track)
##    4: Germany: Lower secondary, access to upper secondary; academic education (exclusively students of the same track)
##    5: Germany: Lower secondary, access to upper secondary; academic education (exclusively students of the same track)
##   ---                                                                                                                 
## 3193:    Germany: Lower secondary comprehensive, achievement-based access to upper secondary (within school streaming)
## 3194:    Germany: Lower secondary comprehensive, achievement-based access to upper secondary (within school streaming)
## 3195:    Germany: Lower secondary comprehensive, achievement-based access to upper secondary (within school streaming)
## 3196:    Germany: Lower secondary comprehensive, achievement-based access to upper secondary (within school streaming)
## 3197:    Germany: Lower secondary comprehensive, achievement-based access to upper secondary (within school streaming)
##              ISCEDL ISCEDD  ISCEDO DISCLISCI TEACHSUP IBTEACH TDTEACH ENVAWARE
##    1: ISCED level 2      A General   -0.2336  -0.8040 -0.6081 -0.8671  -0.5365
##    2: ISCED level 2      A General    0.2829   0.4879 -0.1573 -0.6849  -0.8048
##    3: ISCED level 2      A General    0.7001   1.4475  0.9882  0.5252   0.1710
##    4: ISCED level 2      A General    0.0039   0.5683  0.2087 -0.0742  -0.2342
##    5: ISCED level 2      A General    0.7634  -0.4496  0.5354 -0.0057  -0.4788
##   ---                                                                         
## 3193: ISCED level 2      A General    1.3185   0.7131 -0.0716  0.1910   0.4969
## 3194: ISCED level 2      A General    0.9373   0.9209  1.0631  2.0781  -0.4608
## 3195: ISCED level 2      A General    0.9327  -0.2618 -1.0496 -1.5358   1.3400
## 3196: ISCED level 2      A General   -0.2683  -1.0505  0.3632 -0.0141   2.2983
## 3197: ISCED level 2      A General    0.0039  -0.8613  1.2163  0.5064   0.7295
##        ENVOPT JOYSCIE INTBRSCI INSTSCIE SCIEEFF   EPIST SCIEACT BSMJ GRADE
##    1:  0.1023 -0.8208  -0.5502       NA      NA      NA      NA   NA     0
##    2:  0.1023 -2.1154  -1.1289  -1.9301 -2.8303 -0.6856 -1.7518   42     0
##    3:  0.6937 -1.7159  -0.2246  -0.7182 -2.0922  0.5157 -1.7518   NA     0
##    4: -0.7797 -0.8208  -0.0831  -0.8262 -0.4258  0.8557 -0.1766   NA     1
##    5: -0.2211  0.6126   0.1976  -0.3035 -0.7130  0.3250 -0.7064   NA     1
##   ---                                                                     
## 3193: -1.7932  0.8225   0.9248   1.0218 -0.5699 -0.9398  0.5137   66     1
## 3194:  0.1798  1.3396  -0.0908  -0.5375 -0.7482 -0.7764  0.1676   26     1
## 3195: -0.2615 -1.6457  -0.5234  -0.9572  1.7590 -1.0683  0.2347   45     1
## 3196:  0.9402 -0.1808  -0.6723  -1.0839  0.9718  0.4023  0.4320   48     1
## 3197:  0.2069  0.1287   1.1786   1.7359  0.5407  2.1552  0.0289   71     1
##        IMMIG            MISCED      FISCED            HISCED HOMESCH  ENTUSE
##    1: Native              <NA>    ISCED 5B          ISCED 5B -0.5712 -0.4097
##    2: Native ISCED 3A, ISCED 4     ISCED 2 ISCED 3A, ISCED 4 -0.8913 -0.7527
##    3: Native       ISCED 5A, 6     ISCED 2       ISCED 5A, 6  0.3373  0.4811
##    4: Native       ISCED 5A, 6 ISCED 5A, 6       ISCED 5A, 6  0.0873  0.6122
##    5: Native ISCED 3A, ISCED 4     ISCED 2 ISCED 3A, ISCED 4 -0.2224 -0.0919
##   ---                                                                       
## 3193: Native           ISCED 2     ISCED 2           ISCED 2 -0.4958 -1.1809
## 3194: Native           ISCED 2 ISCED 3B, C       ISCED 3B, C -0.3600 -0.6209
## 3195: Native           ISCED 2     ISCED 2           ISCED 2 -0.4687 -0.4946
## 3196: Native          ISCED 5B    ISCED 5B          ISCED 5B  0.2532  0.4857
## 3197: Native ISCED 3A, ISCED 4 ISCED 5A, 6       ISCED 5A, 6  0.0373  0.2874
##       BMMJ1 BFMJ2 hisei                   REPEAT
##    1:    28    33    33       Repeated a <grade>
##    2:    43    28    43 Did not repeat a <grade>
##    3:    62    61    62 Did not repeat a <grade>
##    4:    55    88    88 Did not repeat a <grade>
##    5:    60    24    60 Did not repeat a <grade>
##   ---                                           
## 3193:    45    29    45 Did not repeat a <grade>
## 3194:    25    14    25 Did not repeat a <grade>
## 3195:    62    60    62 Did not repeat a <grade>
## 3196:    28    26    28 Did not repeat a <grade>
## 3197:    50    32    50 Did not repeat a <grade>
##                                                         DURECEC OUTHOURS MMINS
##    1: Attended ECEC for at least three but less than four years        6   180
##    2: Attended ECEC for at least three but less than four years       12   180
##    3: Attended ECEC for at least three but less than four years        9   360
##    4: Attended ECEC for at least three but less than four years        5   180
##    5: Attended ECEC for at least three but less than four years        5   180
##   ---                                                                         
## 3193:  Attended ECEC for at least two but less than three years       12   360
## 3194: Attended ECEC for at least three but less than four years       16   180
## 3195:  Attended ECEC for at least four but less than five years        2   180
## 3196: Attended ECEC for at least three but less than four years        7   180
## 3197:  Attended ECEC for at least two but less than three years       18   180
##       LMINS SMINS TMINS  BELONG ANXTEST MOTIVAT COOPERATE CPSVALUE EMOSUPS
##    1:   180   405  1350  0.0171 -0.0345 -2.3950   -0.2882   0.1444 -1.5266
##    2:   180   270  1620  0.6642 -0.5792 -1.0795    1.0205   0.4713  1.0991
##    3:   360   540    NA  1.5043 -0.4331  0.4631    2.2879  -0.1160  1.0991
##    4:   180     0  1485  1.5043 -0.3318 -0.1756   -0.2882  -0.2024 -0.2495
##    5:   180   270  1620 -0.9909 -0.3165 -0.4495   -0.3352  -0.8356  0.1004
##   ---                                                                     
## 3193:   360   540  2700  0.6642  0.2594  0.7050    0.3950  -0.5546  1.0991
## 3194:   180   270  1440  2.5915 -0.2039 -0.8771    2.2879   2.1017  1.0991
## 3195:   180   270  1440 -0.6691  0.5348 -1.4136   -1.1664  -1.2734 -2.0584
## 3196:   180    90  2700  0.2947  1.3418 -1.6781   -0.6180  -1.5663  1.0991
## 3197:   180   180  2025 -1.1565  0.8565 -0.3240    1.0205  -0.8356  1.0991
##       PERFEED  ADINST            SCCHANGE CHANGE SADDINST HADDINST ADDSCIIN
##    1: -1.5255  0.0437           no change      0       NA       NA       NA
##    2: -1.0450 -0.8141          one change      1        2        9       NA
##    3:  0.0933  0.0601           no change      0        3        6       NA
##    4:  0.0134  0.3530           no change      0        5        9       NA
##    5: -1.1537 -0.4268           no change      0        0        0       NA
##   ---                                                                      
## 3193: -0.5356  0.6524                <NA>     NA       NA       NA       NA
## 3194:  0.0134  0.3530 two or more changes      2        0        0       NA
## 3195: -0.4831 -1.2428          one change      1        2        8       NA
## 3196: -0.7766 -1.9656 two or more changes      2        1        2       NA
## 3197:  0.0134  0.9784           no change      0        1        1       NA
##       COMSCSUP COMSCSTRLE COMSCSTRCO COMSCTSREL COMMASUP COMMASTRLE COMMASTRCO
##    1:       NA         NA         NA         NA       NA         NA         NA
##    2:       NA         NA         NA         NA       NA         NA         NA
##    3:       NA         NA         NA         NA       NA         NA         NA
##    4:       NA         NA         NA         NA       NA         NA         NA
##    5:       NA         NA         NA         NA       NA         NA         NA
##   ---                                                                         
## 3193:       NA         NA         NA         NA       NA         NA         NA
## 3194:       NA         NA         NA         NA       NA         NA         NA
## 3195:       NA         NA         NA         NA       NA         NA         NA
## 3196:       NA         NA         NA         NA       NA         NA         NA
## 3197:       NA         NA         NA         NA       NA         NA         NA
##       COMMATSREL  USESCH  INTICT COMPICT  AUTICT SOIAICT ICTHOME ICTSCH PRESUPP
##    1:         NA -1.6678  0.3266 -0.7110  0.5553 -0.6455      NA     NA      NA
##    2:         NA -0.2338  0.6555 -0.7320 -1.2688 -1.0602      NA     NA -3.1278
##    3:         NA -0.4210  0.3961 -1.6468 -1.7750 -1.0722      NA     NA -1.6388
##    4:         NA -0.0341  1.7671 -0.8290 -0.5628 -1.0906      NA     NA      NA
##    5:         NA -0.8849 -0.4025 -1.4877 -0.4607 -0.2160      NA     NA  0.3317
##   ---                                                                          
## 3193:         NA -0.3951      NA      NA      NA      NA      NA     NA -0.2612
## 3194:         NA -0.2858 -1.1085 -0.8237 -0.7496 -1.2871      NA     NA -0.0090
## 3195:         NA -0.4210 -0.8470 -0.2270  0.3663 -0.7726      NA     NA  0.2374
## 3196:         NA -0.6274  2.6352  0.8348  1.2841  1.5243      NA     NA -0.2796
## 3197:         NA -0.4795  2.6352  1.9359  2.0955  1.1420      NA     NA      NA
##       CURSUPP EMOSUPP PQSCHOOL PASCHPOL PQGENSCI PQENPERC PQENVOPT
##    1:      NA      NA       NA       NA       NA       NA       NA
##    2: -0.6814 -0.9094   0.3349  -0.5840  -1.3540  -1.0072   0.6113
##    3:  0.1073  0.7454   0.6209  -0.6194  -0.3603   0.7367  -0.0220
##    4:      NA      NA       NA       NA       NA       NA       NA
##    5: -0.0009  0.7454  -0.2730  -1.1510  -1.1637  -1.7747   0.8175
##   ---                                                             
## 3193: -0.0665  0.1104  -1.5836  -1.4572  -0.1515   0.9201  -1.2620
## 3194: -0.2511  0.7454  -2.8162  -3.0421   1.8963  -1.5887  -1.2620
## 3195: -0.0586 -2.2251  -1.7183  -1.0951  -0.7357  -1.2877   0.1809
## 3196:  0.7781  0.7454   0.0121  -1.2768   1.8963   0.9201  -1.2620
## 3197:      NA      NA       NA       NA       NA       NA       NA
##       unfairteacher PARED                COBN_F
##    1:             9    15               Germany
##    2:             8    13               Germany
##    3:             6    18               Germany
##    4:             8    18               Germany
##    5:            12    13               Germany
##   ---                                          
## 3193:             8    10               Germany
## 3194:             7    13 Another country (DEU)
## 3195:            14    10               Germany
## 3196:            14    15 Another country (DEU)
## 3197:            16    18               Germany
##                                 COBN_M  COBN_S  LANGN
##    1:            Another country (DEU) Germany German
##    2:                          Germany Germany German
##    3:                          Germany Germany German
##    4:                          Germany Germany German
##    5:                          Germany Germany German
##   ---                                                
## 3193:                          Germany Germany German
## 3194:                          Germany Germany German
## 3195:                          Germany Germany German
## 3196:                          Germany Germany German
## 3197: One of the former USSR republics Germany German
##                                               OCOD1
##    1:                         Shop sales assistants
##    2:                         General office clerks
##    3:      Real estate agents and property managers
##    4:      Administrative and executive secretaries
##    5:                     Insurance representatives
##   ---                                              
## 3193:                            Medical assistants
## 3194:                                         Cooks
## 3195: Regulatory government associate professionals
## 3196:                      Personal service workers
## 3197:             Accounting and bookkeeping clerks
##                                                                  OCOD2
##    1:                                                     Stock clerks
##    2:                                            Shop sales assistants
##    3:                                                    Trade brokers
##    4:                                                         Dentists
##    5:                Stonemasons, stone cutters, splitters and carvers
##   ---                                                                 
## 3193:                                        Plumbers and pipe fitters
## 3194: Cleaners and helpers in offices, hotels and other establishments
## 3195:                                        Insurance representatives
## 3196:                                    Heavy truck and lorry drivers
## 3197:    Agricultural and industrial machinery mechanics and repairers
##                                 OCOD3 CULTPOSS  HEDRES HOMEPOS  ICTRES  WEALTH
##    1:                  Not Applicable   2.1655  1.1563  1.5012  0.7936  1.0228
##    2:   Travel consultants and clerks  -0.7273  1.1563 -0.4854 -0.3461 -0.2249
##    3:                  Not Applicable  -0.8341 -0.7218  0.3423  0.4892  1.3528
##    4:                  Not Applicable   1.0478  1.1563  0.9076  0.5970  0.4445
##    5:                  Not Applicable  -0.0971  1.1563 -0.0510 -0.8588 -0.7139
##   ---                                                                         
## 3193:            Health professionals   0.3941  1.1563  0.4752 -0.3461 -0.2635
## 3194:              Child care workers  -0.3560 -0.1108  0.3836  0.6932  1.2341
## 3195:               Ambulance workers  -1.6287 -1.9024 -0.7929  0.0614  0.1861
## 3196: Nursing associate professionals   0.3005  1.1563  0.8117  0.4091  0.4818
## 3197:             Building architects   0.2737 -0.1108  0.7642 -0.0687  0.7604
##          ESCS  W_FSTUWT W_FSTURWT1 W_FSTURWT2 W_FSTURWT3 W_FSTURWT4 W_FSTURWT5
##    1:  0.3306  94.71886   47.35943   47.35943   142.0783   142.0783   142.0783
##    2: -0.4779  94.71886   47.35943   47.35943   142.0783   142.0783   142.0783
##    3:  0.9317  94.71886   47.35943   47.35943   142.0783   142.0783   142.0783
##    4:  1.6767 102.45550   51.62257   53.15760   152.6793   152.6793   152.6793
##    5:  0.0330 102.45550   51.62257   53.15760   152.6793   152.6793   152.6793
##   ---                                                                         
## 3193: -0.5113  91.98511  136.68920  139.74070   136.6892   136.6892   136.6892
## 3194: -0.5305  91.98511  136.68920  139.74070   136.6892   136.6892   136.6892
## 3195: -0.6260  91.98511  136.68920  139.74070   136.6892   136.6892   136.6892
## 3196: -0.0261  91.98511  136.68920  139.74070   136.6892   136.6892   136.6892
## 3197:  0.8388  91.98511  136.68920  139.74070   136.6892   136.6892   136.6892
##       W_FSTURWT6 W_FSTURWT7 W_FSTURWT8 W_FSTURWT9 W_FSTURWT10 W_FSTURWT11
##    1:  142.07830   47.35943   142.0783   47.35943   142.07830    47.35943
##    2:  142.07830   47.35943   142.0783   47.35943   142.07830    47.35943
##    3:  142.07830   47.35943   142.0783   47.35943   142.07830    47.35943
##    4:  150.83360   53.15760   150.8336   53.15760   150.83360    51.62257
##    5:  150.83360   53.15760   150.8336   53.15760   150.83360    51.62257
##   ---                                                                    
## 3193:   45.51079   46.44085   139.7407   45.51079    46.44085   139.74070
## 3194:   45.51079   46.44085   139.7407   45.51079    46.44085   139.74070
## 3195:   45.51079   46.44085   139.7407   45.51079    46.44085   139.74070
## 3196:   45.51079   46.44085   139.7407   45.51079    46.44085   139.74070
## 3197:   45.51079   46.44085   139.7407   45.51079    46.44085   139.74070
##       W_FSTURWT12 W_FSTURWT13 W_FSTURWT14 W_FSTURWT15 W_FSTURWT16 W_FSTURWT17
##    1:    47.35943    47.35943    47.35943   142.07830   142.07830    47.35943
##    2:    47.35943    47.35943    47.35943   142.07830   142.07830    47.35943
##    3:    47.35943    47.35943    47.35943   142.07830   142.07830    47.35943
##    4:    51.62257    51.62257    53.15760   152.67930   150.83360    53.15760
##    5:    51.62257    51.62257    53.15760   152.67930   150.83360    53.15760
##   ---                                                                        
## 3193:   136.68920    45.51079    46.44085    46.44085    46.44085   139.74070
## 3194:   136.68920    45.51079    46.44085    46.44085    46.44085   139.74070
## 3195:   136.68920    45.51079    46.44085    46.44085    46.44085   139.74070
## 3196:   136.68920    45.51079    46.44085    46.44085    46.44085   139.74070
## 3197:   136.68920    45.51079    46.44085    46.44085    46.44085   139.74070
##       W_FSTURWT18 W_FSTURWT19 W_FSTURWT20 W_FSTURWT21 W_FSTURWT22 W_FSTURWT23
##    1:   142.07830    142.0783    47.35943    47.35943    47.35943   142.07830
##    2:   142.07830    142.0783    47.35943    47.35943    47.35943   142.07830
##    3:   142.07830    142.0783    47.35943    47.35943    47.35943   142.07830
##    4:   152.67930    150.8336    51.62257    51.62257    53.15760   152.67930
##    5:   152.67930    150.8336    51.62257    51.62257    53.15760   152.67930
##   ---                                                                        
## 3193:    45.51079    139.7407    45.51079    46.44085    45.51079    46.44085
## 3194:    45.51079    139.7407    45.51079    46.44085    45.51079    46.44085
## 3195:    45.51079    139.7407    45.51079    46.44085    45.51079    46.44085
## 3196:    45.51079    139.7407    45.51079    46.44085    45.51079    46.44085
## 3197:    45.51079    139.7407    45.51079    46.44085    45.51079    46.44085
##       W_FSTURWT24 W_FSTURWT25 W_FSTURWT26 W_FSTURWT27 W_FSTURWT28 W_FSTURWT29
##    1:   142.07830   142.07830    142.0783    47.35943   142.07830    47.35943
##    2:   142.07830   142.07830    142.0783    47.35943   142.07830    47.35943
##    3:   142.07830   142.07830    142.0783    47.35943   142.07830    47.35943
##    4:   152.67930   152.67930    150.8336    53.15760   150.83360    53.15760
##    5:   152.67930   152.67930    150.8336    53.15760   150.83360    53.15760
##   ---                                                                        
## 3193:    46.44085    46.44085    139.7407   136.68920    45.51079   139.74070
## 3194:    46.44085    46.44085    139.7407   136.68920    45.51079   139.74070
## 3195:    46.44085    46.44085    139.7407   136.68920    45.51079   139.74070
## 3196:    46.44085    46.44085    139.7407   136.68920    45.51079   139.74070
## 3197:    46.44085    46.44085    139.7407   136.68920    45.51079   139.74070
##       W_FSTURWT30 W_FSTURWT31 W_FSTURWT32 W_FSTURWT33 W_FSTURWT34 W_FSTURWT35
##    1:    142.0783    47.35943    47.35943    47.35943    47.35943    142.0783
##    2:    142.0783    47.35943    47.35943    47.35943    47.35943    142.0783
##    3:    142.0783    47.35943    47.35943    47.35943    47.35943    142.0783
##    4:    150.8336    51.62257    51.62257    51.62257    53.15760    152.6793
##    5:    150.8336    51.62257    51.62257    51.62257    53.15760    152.6793
##   ---                                                                        
## 3193:    136.6892    45.51079    46.44085   139.74070   136.68920    136.6892
## 3194:    136.6892    45.51079    46.44085   139.74070   136.68920    136.6892
## 3195:    136.6892    45.51079    46.44085   139.74070   136.68920    136.6892
## 3196:    136.6892    45.51079    46.44085   139.74070   136.68920    136.6892
## 3197:    136.6892    45.51079    46.44085   139.74070   136.68920    136.6892
##       W_FSTURWT36 W_FSTURWT37 W_FSTURWT38 W_FSTURWT39 W_FSTURWT40 W_FSTURWT41
##    1:    142.0783    47.35943    142.0783   142.07830    47.35943    47.35943
##    2:    142.0783    47.35943    142.0783   142.07830    47.35943    47.35943
##    3:    142.0783    47.35943    142.0783   142.07830    47.35943    47.35943
##    4:    150.8336    53.15760    152.6793   150.83360    51.62257    51.62257
##    5:    150.8336    53.15760    152.6793   150.83360    51.62257    51.62257
##   ---                                                                        
## 3193:    136.6892    45.51079    139.7407    45.51079   139.74070   136.68920
## 3194:    136.6892    45.51079    139.7407    45.51079   139.74070   136.68920
## 3195:    136.6892    45.51079    139.7407    45.51079   139.74070   136.68920
## 3196:    136.6892    45.51079    139.7407    45.51079   139.74070   136.68920
## 3197:    136.6892    45.51079    139.7407    45.51079   139.74070   136.68920
##       W_FSTURWT42 W_FSTURWT43 W_FSTURWT44 W_FSTURWT45 W_FSTURWT46 W_FSTURWT47
##    1:    47.35943    142.0783    142.0783    142.0783   142.07830    47.35943
##    2:    47.35943    142.0783    142.0783    142.0783   142.07830    47.35943
##    3:    47.35943    142.0783    142.0783    142.0783   142.07830    47.35943
##    4:    53.15760    152.6793    152.6793    152.6793   150.83360    53.15760
##    5:    53.15760    152.6793    152.6793    152.6793   150.83360    53.15760
##   ---                                                                        
## 3193:   139.74070    136.6892    136.6892    136.6892    45.51079    46.44085
## 3194:   139.74070    136.6892    136.6892    136.6892    45.51079    46.44085
## 3195:   139.74070    136.6892    136.6892    136.6892    45.51079    46.44085
## 3196:   139.74070    136.6892    136.6892    136.6892    45.51079    46.44085
## 3197:   139.74070    136.6892    136.6892    136.6892    45.51079    46.44085
##       W_FSTURWT48 W_FSTURWT49 W_FSTURWT50 W_FSTURWT51 W_FSTURWT52 W_FSTURWT53
##    1:    142.0783    47.35943   142.07830    47.35943    47.35943    47.35943
##    2:    142.0783    47.35943   142.07830    47.35943    47.35943    47.35943
##    3:    142.0783    47.35943   142.07830    47.35943    47.35943    47.35943
##    4:    150.8336    53.15760   150.83360    51.62257    51.62257    51.62257
##    5:    150.8336    53.15760   150.83360    51.62257    51.62257    51.62257
##   ---                                                                        
## 3193:    139.7407    45.51079    46.44085   139.74070   136.68920    45.51079
## 3194:    139.7407    45.51079    46.44085   139.74070   136.68920    45.51079
## 3195:    139.7407    45.51079    46.44085   139.74070   136.68920    45.51079
## 3196:    139.7407    45.51079    46.44085   139.74070   136.68920    45.51079
## 3197:    139.7407    45.51079    46.44085   139.74070   136.68920    45.51079
##       W_FSTURWT54 W_FSTURWT55 W_FSTURWT56 W_FSTURWT57 W_FSTURWT58 W_FSTURWT59
##    1:    47.35943   142.07830   142.07830    47.35943   142.07830    142.0783
##    2:    47.35943   142.07830   142.07830    47.35943   142.07830    142.0783
##    3:    47.35943   142.07830   142.07830    47.35943   142.07830    142.0783
##    4:    53.15760   152.67930   150.83360    53.15760   152.67930    150.8336
##    5:    53.15760   152.67930   150.83360    53.15760   152.67930    150.8336
##   ---                                                                        
## 3193:    46.44085    46.44085    46.44085   139.74070    45.51079    139.7407
## 3194:    46.44085    46.44085    46.44085   139.74070    45.51079    139.7407
## 3195:    46.44085    46.44085    46.44085   139.74070    45.51079    139.7407
## 3196:    46.44085    46.44085    46.44085   139.74070    45.51079    139.7407
## 3197:    46.44085    46.44085    46.44085   139.74070    45.51079    139.7407
##       W_FSTURWT60 W_FSTURWT61 W_FSTURWT62 W_FSTURWT63 W_FSTURWT64 W_FSTURWT65
##    1:    47.35943    47.35943    47.35943   142.07830   142.07830   142.07830
##    2:    47.35943    47.35943    47.35943   142.07830   142.07830   142.07830
##    3:    47.35943    47.35943    47.35943   142.07830   142.07830   142.07830
##    4:    51.62257    51.62257    53.15760   152.67930   152.67930   152.67930
##    5:    51.62257    51.62257    53.15760   152.67930   152.67930   152.67930
##   ---                                                                        
## 3193:    45.51079    46.44085    45.51079    46.44085    46.44085    46.44085
## 3194:    45.51079    46.44085    45.51079    46.44085    46.44085    46.44085
## 3195:    45.51079    46.44085    45.51079    46.44085    46.44085    46.44085
## 3196:    45.51079    46.44085    45.51079    46.44085    46.44085    46.44085
## 3197:    45.51079    46.44085    45.51079    46.44085    46.44085    46.44085
##       W_FSTURWT66 W_FSTURWT67 W_FSTURWT68 W_FSTURWT69 W_FSTURWT70 W_FSTURWT71
##    1:    142.0783    47.35943   142.07830    47.35943    142.0783    47.35943
##    2:    142.0783    47.35943   142.07830    47.35943    142.0783    47.35943
##    3:    142.0783    47.35943   142.07830    47.35943    142.0783    47.35943
##    4:    150.8336    53.15760   150.83360    53.15760    150.8336    51.62257
##    5:    150.8336    53.15760   150.83360    53.15760    150.8336    51.62257
##   ---                                                                        
## 3193:    139.7407   136.68920    45.51079   139.74070    136.6892    45.51079
## 3194:    139.7407   136.68920    45.51079   139.74070    136.6892    45.51079
## 3195:    139.7407   136.68920    45.51079   139.74070    136.6892    45.51079
## 3196:    139.7407   136.68920    45.51079   139.74070    136.6892    45.51079
## 3197:    139.7407   136.68920    45.51079   139.74070    136.6892    45.51079
##       W_FSTURWT72 W_FSTURWT73 W_FSTURWT74 W_FSTURWT75 W_FSTURWT76 W_FSTURWT77
##    1:    47.35943    47.35943    47.35943    142.0783    142.0783    47.35943
##    2:    47.35943    47.35943    47.35943    142.0783    142.0783    47.35943
##    3:    47.35943    47.35943    47.35943    142.0783    142.0783    47.35943
##    4:    51.62257    51.62257    53.15760    152.6793    150.8336    53.15760
##    5:    51.62257    51.62257    53.15760    152.6793    150.8336    53.15760
##   ---                                                                        
## 3193:    46.44085   139.74070   136.68920    136.6892    136.6892    45.51079
## 3194:    46.44085   139.74070   136.68920    136.6892    136.6892    45.51079
## 3195:    46.44085   139.74070   136.68920    136.6892    136.6892    45.51079
## 3196:    46.44085   139.74070   136.68920    136.6892    136.6892    45.51079
## 3197:    46.44085   139.74070   136.68920    136.6892    136.6892    45.51079
##       W_FSTURWT78 W_FSTURWT79 W_FSTURWT80                  UNIT WVARSTRR
##    1:    142.0783   142.07830    47.35943 final variance unit 2       76
##    2:    142.0783   142.07830    47.35943 final variance unit 2       76
##    3:    142.0783   142.07830    47.35943 final variance unit 2       76
##    4:    152.6793   150.83360    51.62257 final variance unit 2       76
##    5:    152.6793   150.83360    51.62257 final variance unit 2       76
##   ---                                                                   
## 3193:    139.7407    45.51079   139.74070 final variance unit 1        1
## 3194:    139.7407    45.51079   139.74070 final variance unit 1        1
## 3195:    139.7407    45.51079   139.74070 final variance unit 1        1
## 3196:    139.7407    45.51079   139.74070 final variance unit 1        1
## 3197:    139.7407    45.51079   139.74070 final variance unit 1        1
##       PV1MATH PV2MATH PV3MATH PV4MATH PV5MATH PV6MATH PV7MATH PV8MATH PV9MATH
##    1: 471.469 433.091 478.145 484.535 509.322 512.629 478.540 465.075 521.418
##    2: 516.694 409.077 432.485 447.409 525.874 502.626 458.893 463.910 445.486
##    3: 595.801 620.434 630.390 661.464 602.072 569.159 552.163 576.496 555.388
##    4: 464.959 565.340 546.584 551.572 537.498 530.947 562.206 567.884 508.543
##    5: 544.310 601.055 549.590 557.509 565.706 536.137 527.026 553.822 508.409
##   ---                                                                        
## 3193: 574.924 605.614 559.850 564.389 634.468 599.524 550.830 581.604 580.090
## 3194: 466.676 488.476 503.313 465.909 455.704 485.869 390.392 466.786 492.069
## 3195: 481.228 516.015 455.952 529.213 499.952 485.485 524.239 471.843 512.693
## 3196: 484.930 569.295 451.395 474.341 405.751 442.047 398.160 504.601 393.980
## 3197: 453.889 457.048 450.982 420.268 457.789 402.964 434.073 373.907 507.135
##       PV10MATH PV1READ PV2READ PV3READ PV4READ PV5READ PV6READ PV7READ PV8READ
##    1:  521.211 502.003 496.498 565.270 483.306 526.473 571.484 504.256 540.133
##    2:  445.532 487.315 506.952 467.286 514.270 530.564 551.389 507.908 522.084
##    3:  595.139 662.796 669.937 712.614 676.133 655.724 611.293 570.889 639.288
##    4:  485.894 571.859 617.071 642.228 629.897 615.486 664.547 680.693 635.283
##    5:  551.410 502.153 609.559 457.285 573.686 603.908 600.070 532.382 547.934
##   ---                                                                         
## 3193:  610.191 565.173 589.183 545.499 526.549 594.841 599.656 564.761 605.990
## 3194:  483.722 468.543 500.846 483.114 481.048 470.344 502.570 472.789 484.206
## 3195:  515.443 469.214 497.507 473.499 565.520 541.649 483.492 577.923 469.681
## 3196:  498.056 514.441 555.882 438.760 577.504 556.342 511.922 535.354 518.674
## 3197:  521.085 473.345 490.194 453.271 467.869 484.351 496.412 466.983 423.968
##       PV9READ PV10READ PV1SCIE PV2SCIE PV3SCIE PV4SCIE PV5SCIE PV6SCIE PV7SCIE
##    1: 542.179  560.011 456.902 438.004 545.892 479.152 534.589 480.263 536.195
##    2: 588.696  489.149 505.239 496.490 481.493 483.617 487.581 507.067 469.419
##    3: 653.044  724.243 566.428 573.291 605.697 596.867 563.718 590.518 557.647
##    4: 623.691  680.139 502.316 559.056 567.788 558.837 560.699 554.882 595.206
##    5: 546.370  517.088 546.052 551.288 585.787 554.661 580.118 559.199 545.550
##   ---                                                                         
## 3193: 596.397  631.526 642.547 602.784 612.358 559.039 633.847 643.724 574.740
## 3194: 473.132  462.372 462.247 460.016 477.083 471.114 465.200 466.343 453.367
## 3195: 494.513  520.552 465.048 540.221 460.978 518.033 495.812 467.595 565.344
## 3196: 416.386  531.113 510.979 548.805 506.677 543.929 494.295 501.528 538.732
## 3197: 451.623  501.428 479.236 476.725 493.800 456.413 447.858 431.566 445.621
##       PV8SCIE PV9SCIE PV10SCIE PV1SCEP PV2SCEP PV3SCEP PV4SCEP PV5SCEP PV6SCEP
##    1: 464.027 541.845  551.729 511.466 502.423 475.693 518.713 592.368 528.154
##    2: 528.069 447.494  472.618 458.181 478.992 485.819 429.703 497.461 429.062
##    3: 578.396 588.283  576.174 515.727 562.030 549.460 538.292 548.910 532.647
##    4: 556.903 568.702  522.576 559.426 501.254 562.084 473.153 546.513 553.799
##    5: 586.696 519.772  538.775 547.676 532.270 561.320 463.304 537.240 548.220
##   ---                                                                         
## 3193: 609.382 586.694  620.580 653.032 583.725 570.678 587.251 533.071 587.347
## 3194: 453.375 493.701  492.639 559.561 506.976 468.344 482.271 538.393 498.655
## 3195: 442.223 475.526  482.813 551.680 504.918 517.353 553.283 441.574 532.672
## 3196: 519.336 504.437  513.425 553.313 505.058 560.123 531.482 528.185 477.048
## 3197: 416.007 488.881  474.947 476.728 492.336 470.786 476.805 469.611 464.454
##       PV7SCEP PV8SCEP PV9SCEP PV10SCEP PV1SCED PV2SCED PV3SCED PV4SCED PV5SCED
##    1: 515.300 518.458 453.544  494.859 554.012 509.930 534.783 552.525 621.201
##    2: 505.891 504.342 560.448  480.020 524.697 515.923 502.114 512.534 523.950
##    3: 570.466 621.923 565.085  555.018 566.351 581.836 563.602 553.363 526.480
##    4: 552.285 549.551 582.430  522.017 607.946 527.629 580.106 494.238 566.784
##    5: 563.037 508.751 564.796  552.325 649.122 614.135 657.992 576.735 584.267
##   ---                                                                         
## 3193: 671.880 548.459 582.301  570.244 641.879 637.407 590.416 615.795 614.598
## 3194: 529.629 512.731 495.750  544.002 448.869 458.751 401.213 500.799 524.820
## 3195: 488.685 550.127 451.345  556.797 474.191 494.869 469.815 495.007 464.220
## 3196: 533.382 521.433 509.473  526.961 513.231 509.394 496.834 556.466 564.974
## 3197: 490.299 514.824 490.493  456.371 429.104 466.210 414.329 527.033 487.034
##       PV6SCED PV7SCED PV8SCED PV9SCED PV10SCED PV1SCID PV2SCID PV3SCID PV4SCID
##    1: 511.885 529.636 586.984 489.215  577.563 503.105 500.639 467.085 513.940
##    2: 454.407 569.635 573.781 577.623  525.542 530.770 502.422 550.576 528.486
##    3: 595.490 576.972 639.832 611.890  552.712 534.630 604.790 547.097 557.023
##    4: 599.574 575.351 607.167 589.766  536.909 594.585 563.989 581.284 464.846
##    5: 617.811 613.911 606.751 610.775  699.580 592.376 570.833 549.657 544.071
##   ---                                                                         
## 3193: 603.622 673.494 560.256 621.028  588.443 613.682 608.998 552.519 599.806
## 3194: 512.058 431.888 439.159 405.975  491.533 464.907 479.382 438.467 476.415
## 3195: 511.208 499.441 502.721 388.677  558.401 498.056 536.459 491.422 527.909
## 3196: 491.181 540.432 532.684 508.429  539.952 468.915 478.354 477.014 526.633
## 3197: 468.273 518.858 486.320 459.884  430.763 378.416 498.510 392.653 428.619
##       PV5SCID PV6SCID PV7SCID PV8SCID PV9SCID PV10SCID PV1SKCO PV2SKCO PV3SKCO
##    1: 572.853 511.661 511.147 530.869 420.499  525.487 536.572 543.306 508.493
##    2: 508.313 481.899 555.016 570.108 562.018  556.380 497.475 486.921 461.571
##    3: 551.802 560.004 597.838 641.167 610.791  552.798 600.282 565.166 553.559
##    4: 595.743 591.163 635.995 603.334 611.023  562.271 532.465 532.056 572.909
##    5: 556.435 564.809 599.003 541.340 596.860  580.646 524.830 593.957 570.505
##   ---                                                                         
## 3193: 590.229 607.175 659.579 550.655 602.715  530.822 645.447 625.133 549.410
## 3194: 487.128 425.480 514.925 501.506 444.241  488.197 503.125 511.844 469.682
## 3195: 430.063 540.295 507.010 542.739 458.691  543.035 470.865 461.423 499.517
## 3196: 505.620 466.684 476.709 547.622 495.517  488.194 568.623 555.900 546.604
## 3197: 418.326 435.227 451.680 447.013 465.804  425.325 490.683 453.160 473.240
##       PV4SKCO PV5SKCO PV6SKCO PV7SKCO PV8SKCO PV9SKCO PV10SKCO PV1SKPE PV2SKPE
##    1: 490.286 437.696 477.196 507.278 467.605 515.512  473.464 541.963 553.448
##    2: 528.434 429.679 478.502 469.696 454.217 457.975  471.050 497.574 509.577
##    3: 579.229 609.308 561.027 611.243 535.003 589.938  583.380 591.829 576.560
##    4: 497.556 493.248 476.353 512.378 498.864 489.904  529.944 505.595 564.459
##    5: 560.844 501.846 539.959 514.480 533.800 559.101  610.134 578.684 607.295
##   ---                                                                         
## 3193: 608.496 560.145 615.635 648.844 628.501 563.165  652.049 643.574 615.618
## 3194: 510.264 530.790 485.132 492.961 490.315 463.087  534.269 441.862 439.312
## 3195: 477.861 417.012 437.089 452.354 501.028 452.174  481.964 486.278 487.945
## 3196: 586.305 540.930 494.787 528.498 563.168 512.523  558.586 546.703 522.497
## 3197: 492.769 452.542 466.986 446.486 464.195 443.000  547.519 458.496 377.026
##       PV3SKPE PV4SKPE PV5SKPE PV6SKPE PV7SKPE PV8SKPE PV9SKPE PV10SKPE PV1SSPH
##    1: 507.480 532.879 492.459 503.294 540.777 475.915 561.557  505.842 525.426
##    2: 549.869 550.918 503.068 514.687 505.935 521.457 496.892  505.798 498.500
##    3: 547.610 579.692 622.797 625.389 623.122 584.205 607.029  640.021 601.757
##    4: 565.627 523.211 564.545 565.149 545.055 558.172 547.863  555.345 581.584
##    5: 594.884 616.365 556.785 566.987 548.954 595.943 593.590  601.215 579.246
##   ---                                                                         
## 3193: 567.827 589.863 554.035 575.435 626.355 581.377 594.388  609.728 614.319
## 3194: 495.906 476.379 451.901 462.685 473.419 471.096 446.178  455.809 433.281
## 3195: 555.099 425.594 452.599 476.304 477.839 480.650 470.261  519.494 500.432
## 3196: 504.258 565.715 510.397 520.550 485.728 504.861 502.375  474.333 507.518
## 3197: 430.395 480.491 442.679 472.644 414.736 410.383 463.828  495.938 488.404
##       PV2SSPH PV3SSPH PV4SSPH PV5SSPH PV6SSPH PV7SSPH PV8SSPH PV9SSPH PV10SSPH
##    1: 512.134 523.128 611.146 508.269 551.374 416.859 523.044 519.577  511.461
##    2: 475.757 442.594 505.965 477.883 444.443 498.645 424.467 458.719  409.577
##    3: 560.042 596.354 562.569 567.467 565.444 560.480 591.085 557.592  505.805
##    4: 569.810 550.000 585.721 555.223 576.684 519.607 581.644 565.688  551.478
##    5: 616.823 612.351 592.663 614.627 614.457 611.019 597.431 627.540  647.663
##   ---                                                                         
## 3193: 611.378 577.384 620.686 627.139 558.871 670.397 592.947 556.802  627.678
## 3194: 488.874 407.251 457.484 462.448 447.679 471.522 491.419 552.217  482.668
## 3195: 529.908 457.578 451.837 476.183 476.267 431.263 498.842 459.896  465.711
## 3196: 506.717 498.221 448.471 530.716 504.428 483.568 476.469 487.320  480.907
## 3197: 473.791 432.351 464.737 408.796 439.681 461.396 392.871 437.124  456.191
##       PV1SSLI PV2SSLI PV3SSLI PV4SSLI PV5SSLI PV6SSLI PV7SSLI PV8SSLI PV9SSLI
##    1: 521.651 537.710 510.922 587.292 492.602 528.213 430.859 531.610 516.416
##    2: 542.020 478.719 461.717 506.276 497.478 489.081 520.996 467.326 427.862
##    3: 559.741 588.303 563.789 586.021 562.624 590.676 553.712 540.019 584.200
##    4: 599.781 563.713 571.059 549.868 501.227 568.876 535.555 569.010 523.729
##    5: 541.462 607.407 578.817 575.471 529.124 552.320 565.654 478.199 592.747
##   ---                                                                        
## 3193: 610.180 605.320 600.276 580.106 615.268 578.643 634.545 651.211 560.845
## 3194: 490.266 440.704 487.583 450.842 536.020 456.181 450.958 480.892 516.542
## 3195: 529.721 551.118 486.739 527.697 566.181 515.970 446.769 486.421 462.921
## 3196: 511.888 540.565 551.855 523.931 503.698 526.677 544.697 565.964 529.979
## 3197: 448.114 453.436 470.345 440.248 387.409 427.414 496.271 409.607 415.160
##       PV10SSLI PV1SSES PV2SSES PV3SSES PV4SSES PV5SSES PV6SSES PV7SSES PV8SSES
##    1:  491.594 512.654 510.956 492.811 550.701 468.539 499.703 445.586 518.914
##    2:  447.531 504.437 507.769 439.706 513.214 497.142 456.583 515.783 432.630
##    3:  536.087 605.421 591.910 563.616 590.108 588.362 602.514 532.261 542.795
##    4:  555.175 585.305 558.026 552.973 541.945 541.455 555.335 517.293 531.152
##    5:  597.970 562.204 575.104 581.441 560.578 555.000 571.226 566.072 533.328
##   ---                                                                         
## 3193:  645.547 589.850 630.844 596.367 625.576 593.585 623.862 638.028 615.175
## 3194:  514.458 471.670 563.569 439.659 512.396 510.050 485.940 428.223 489.456
## 3195:  551.828 453.414 549.236 521.930 486.107 502.460 487.532 447.816 551.896
## 3196:  534.788 484.255 498.800 552.386 525.242 470.891 507.746 486.418 539.775
## 3197:  453.747 476.050 497.970 499.658 480.599 409.286 453.592 511.962 412.686
##       PV9SSES PV10SSES   SENWT          VER_DAT
##    1: 458.889  510.986 0.63838 15NOV16:14:44:40
##    2: 407.364  444.321 0.63838 15NOV16:14:44:40
##    3: 647.386  555.328 0.63838 15NOV16:14:44:40
##    4: 506.714  565.169 0.69052 15NOV16:14:44:40
##    5: 556.711  653.884 0.69052 15NOV16:14:44:40
##   ---                                          
## 3193: 618.419  645.697 0.61995 15NOV16:14:44:40
## 3194: 649.440  539.028 0.61995 15NOV16:14:44:40
## 3195: 429.580  518.244 0.61995 15NOV16:14:44:40
## 3196: 481.877  523.803 0.61995 15NOV16:14:44:40
## 3197: 478.462  465.851 0.61995 15NOV16:14:44:40
  1. How many students are there in Germany?
pisa[CNTRYID == "Germany" & ST004D01T == "Female", 
     .N]
## [1] 3197
  1. The .N function returns the length of a vector/ number of rows. Use chaining with the .N function to answer Exercise 2
pisa[CNTRYID == "Germany" & ST004D01T == "Female"
     ][,.N]
## [1] 3197

General Learnings Using j we can: - select columns - summarize variables by performing actions on the variables - and create new variables.

pisa[, 
     .(CNTRYID)] #.() is a shorthand for list()
##                 CNTRYID
##      1:       Australia
##      2:       Australia
##      3:       Australia
##      4:       Australia
##      5:       Australia
##     ---                
## 158057: B-S-J-G (China)
## 158058: B-S-J-G (China)
## 158059: B-S-J-G (China)
## 158060: B-S-J-G (China)
## 158061: B-S-J-G (China)

4.4.1 Exercises

First, create a function to convert dichotomous variable to numeric scoring x a character vector containing “Yes” and “No” responses

bin.to.num <- function(x){
  if(is.na(x)) NA
  else if (x == "Yes") 1L
  else if (x == "No") 0L #L is to make sure variable is treated as interger
}

Then use this function to create some variables as well as recoding gender

pisa[, `:=` (female = ifelse(ST004D01T == "Female", 1, 0),
             sex = ST004D01T, #the := adds the variables directly to the DT
             
             # At my house we have ... 
             desk = sapply(ST011Q01TA, bin.to.num), 
             own.room = sapply(ST011Q02TA, bin.to.num), 
             quiet.study = sapply(ST011Q03TA, bin.to.num), 
             computer = sapply(ST011Q04TA, bin.to.num), 
             software = sapply(ST011Q05TA, bin.to.num),
             internet = sapply(ST011Q06TA, bin.to.num), 
             lit = sapply(ST011Q07TA, bin.to.num), 
             poetry = sapply(ST011Q08TA, bin.to.num), 
             art = sapply(ST011Q09TA, bin.to.num), 
             book.sch = sapply(ST011Q10TA, bin.to.num), 
             tech.book = sapply(ST011Q11TA, bin.to.num), 
             dict = sapply(ST011Q12TA, bin.to.num), 
             art.book = sapply(ST011Q16NA, bin.to.num))]

Then create new variables by combining preexisiting ones

pisa[, `:=` 
     (math = rowMeans(pisa[, c(paste0("PV", 1:10, "MATH"))], na.rm = TRUE), 
       reading = rowMeans(pisa[, c(paste0("PV", 1:10, "READ"))], na.rm = TRUE), 
       science = rowMeans(pisa[, c(paste0("PV", 1:10, "SCIE"))], na.rm = TRUE))]
  1. The computer and software variables that were created above ask a student whether they had a computer in their home that they can use for school work (computer) and whether they had educational software in their home (software). Find the proportion of students in Germany and Uruguay that have a computer in their home or have educational software.
pisa[CNTRYID %in% c("Germany", "Uruguay"),
     table(computer, software)]
##         software
## computer    0    1
##        0  745  101
##        1 5280 4669
#Adding labels/ make it look prettier
pisa[CNTRYID %in% c("Germany", "Uruguay"),
     .(computer = factor(ST011Q04TA, levels = c("No", "Yes")),
       software = factor(ST011Q05TA, levels = c("No", "Yes")))
][,
  table(computer, software)
]
##         software
## computer   No  Yes
##      No   745  101
##      Yes 5280 4669

The total number of students in Germany and Uruguay that have a computer in their home OR have educational software is 101 + 5280 + 4669 = 10050; proportion = 10050/10795 = .93

  1. For just female students, find the proportion of students who have their own room (own.room) or a quiet place to study (quiet.study).
pisa[sex == "Female",
     table(own.room, quiet.study)]
##         quiet.study
## own.room     0     1
##        0  4928 10680
##        1  5828 51172

The total number of female students who have their own room OR a quiet place to study is 5828 + 10680 + 51172 = 67680; proportion = 67680/ 72608 = .93

4.5.1 Exercises

  1. Calculate the proportion of students who have art in their home (art) and the average age (AGE) of the students by gender.
pisa[,
     .(art = mean(art, na.rm = TRUE),
       AGE = mean(AGE, na.rm = TRUE)),
     by = .(sex)]
##       sex       art      AGE
## 1: Female 0.5806813 15.81553
## 2:   Male 0.5624181 15.81395
  1. Within a by argument you can discretize a variable to create a grouping variable. Perform a median split for age within the by argument and assess whether there are age difference associated with having your own room (own.room) or a desk (desk).
pisa[,
     .(own.room = mean(own.room, na.rm = TRUE),
       desk = mean(desk, na.rm = TRUE)),
     by =.(age = (AGE < median(AGE)))
     ]
##      age  own.room      desk
## 1: FALSE 0.7962661 0.8187880
## 2:  TRUE 0.7993508 0.8385361
#Older students (above median age) are more likely to have their own room and desks

4.8 Lab

This afternoon when we discuss supervised learning, we’ll ask you to develop some models to predict the response to the question. Do you expect your child will go into a ?” (PA032Q03TA).

  1. Recode this variable so that a “Yes” is 1 and a “No” is a -1. Save the variable as sci_car
pisa[, 
     "sci_car" := sapply(PA032Q03TA,
                   function(x){
                     if(is.na(x)) NA
                     else if (x == "Yes") 1L
                     else if (x == "No") -1L
                   })
     ][,
       table(sci_car)]
## sci_car
##    -1     1 
## 17680 11575
  1. Calculate descriptives for this variable by sex and country. Specifically, the proportion of test takers whose parents said “Yes” or 1.
pisa[,
     .(sci_car = mean(sci_car, na.rm =TRUE)),
     by = .(sex = sex, country = CNTRYID)]
##        sex         country     sci_car
##  1: Female       Australia         NaN
##  2:   Male       Australia         NaN
##  3:   Male          Brazil         NaN
##  4: Female          Brazil         NaN
##  5: Female          Canada         NaN
##  6:   Male          Canada         NaN
##  7: Female        Colombia         NaN
##  8:   Male        Colombia         NaN
##  9: Female          France -0.35842027
## 10:   Male          France -0.21721478
## 11: Female         Germany -0.83480176
## 12:   Male         Germany -0.70852921
## 13: Female          Israel         NaN
## 14:   Male          Israel         NaN
## 15: Female           Italy -0.44499774
## 16:   Male           Italy -0.26525766
## 17: Female           Japan         NaN
## 18:   Male           Japan         NaN
## 19:   Male          Jordan         NaN
## 20: Female          Jordan         NaN
## 21: Female           Korea -0.44214559
## 22:   Male           Korea -0.07555871
## 23: Female         Lebanon         NaN
## 24:   Male         Lebanon         NaN
## 25:   Male          Mexico  0.39756098
## 26: Female          Mexico  0.32005772
## 27: Female     New Zealand         NaN
## 28:   Male     New Zealand         NaN
## 29:   Male   United States         NaN
## 30: Female   United States         NaN
## 31: Female         Uruguay         NaN
## 32:   Male         Uruguay         NaN
## 33: Female B-S-J-G (China)         NaN
## 34:   Male B-S-J-G (China)         NaN
##        sex         country     sci_car

After you’ve done this, spend some time investigating the following variables Label and then do the following using data.table and/or sparklyr:

  1. Means and standard deviations (sd) for the variables that you think will be most predictive of sci_car

As this is a response by parents, variables that might be the most predictive of sci_car should be observable to parents: Student expected occupational status (BSMJ), Out of school study time (OUTHOURS), Home Educational Resources (HEDRES), Family Wealth (WEALTH)

pisa[,
     .(ExpectedStatus = mean(BSMJ, na.rm = TRUE),
       OutsideStudy = mean(OUTHOURS, na.rm = TRUE),
       HomeRes = mean(HEDRES, na.rm = TRUE),
       Wealth = mean(WEALTH, na.rm = TRUE))
       ]
##    ExpectedStatus OutsideStudy    HomeRes     Wealth
## 1:       61.72995     18.81952 -0.3267211 -0.3924522
  1. Calculate these same descriptives by groups (by sci_car and by sex)
pisa[,
     .(ExpectedStatus = mean(BSMJ, na.rm = TRUE),
       OutsideStudy = mean(OUTHOURS, na.rm = TRUE),
       HomeRes = mean(HEDRES, na.rm = TRUE),
       Wealth = mean(WEALTH, na.rm = TRUE)),
     by = .(sci_car, sex)
]
##    sci_car    sex ExpectedStatus OutsideStudy     HomeRes     Wealth
## 1:      NA Female       64.06874     18.50026 -0.36310480 -0.4382905
## 2:      NA   Male       60.52828     19.59710 -0.36207869 -0.3310930
## 3:       1 Female       67.39607     19.62531 -0.29527963 -0.7163693
## 4:      -1 Female       55.41587     16.65803 -0.07037943 -0.3093473
## 5:      -1   Male       53.34787     17.29241 -0.16207490 -0.2446372
## 6:       1   Male       63.96993     20.14187 -0.24663518 -0.5764796
  1. Calculate correlations between these variables and sci_car
pisa[,
      .(ExpectedStatus = cor(sci_car, BSMJ, use = "na.or.complete"),
        OutsideStudy = cor(sci_car, OUTHOURS, use = "na.or.complete"),
        HomeRes = cor(sci_car, HEDRES, use = "na.or.complete"),
        Wealth = cor(sci_car, WEALTH, use = "na.or.complete"))]
##    ExpectedStatus OutsideStudy    HomeRes     Wealth
## 1:      0.3155443    0.1088173 -0.0744448 -0.1638986
  1. Create new variables 6a. Discretize the math and reading variables using the OECD means (490 for math and 493) and code them as 1 (at or above the mean) and -1 (below the mean), but do in the data.table way without using the $ operator.
pisa[, 
     "mathfac" := sapply(math,
                         function(x){
                           if(is.na(x)) NA
                           else if (x >= 490) 1L
                           else if (x < 490) -1L
                         })]

pisa[, 
     "readfac" := sapply(reading,
                         function(x){
                           if(is.na(x)) NA
                           else if (x >= 493) 1L
                           else if (x < 493) -1L
                         })]

6b. Calculate the correlation between these variables and the list of variables above.

pisa[,
     .(ExpectedStatusM = cor(mathfac, BSMJ, use = "na.or.complete"),
       OutsideStudyM = cor(mathfac, OUTHOURS, use = "na.or.complete"),
       HomeResM = cor(mathfac, HEDRES, use = "na.or.complete"),
       WealthM = cor(mathfac, WEALTH, use = "na.or.complete"),
       ExpectedStatusR = cor(readfac, BSMJ, use = "na.or.complete"),
       OutsideStudyR = cor(readfac, OUTHOURS, use = "na.or.complete"),
       HomeResR = cor(readfac, HEDRES, use = "na.or.complete"),
       WealthR = cor(readfac, WEALTH, use = "na.or.complete"))]
##    ExpectedStatusM OutsideStudyM  HomeResM   WealthM ExpectedStatusR
## 1:        0.069999   -0.07348207 0.2774099 0.2832184       0.1121201
##    OutsideStudyR  HomeResR   WealthR
## 1:   -0.09406116 0.2754228 0.2851246
  1. Chain together a set of operations. For example, create an intermediate variable that is the average of JOYSCIE and INTBRSCI,and then calculate the mean by country by sci_car through chaining
pisa[,
     "lovescience" := ((JOYSCIE + INTBRSCI)/2)
     ][,
       .(sci_car = mean(sci_car, na.rm = TRUE)),
       by = .(CNTRYID)]
##             CNTRYID    sci_car
##  1:       Australia        NaN
##  2:          Brazil        NaN
##  3:          Canada        NaN
##  4:        Colombia        NaN
##  5:          France -0.2908490
##  6:         Germany -0.7779123
##  7:          Israel        NaN
##  8:           Italy -0.3572836
##  9:           Japan        NaN
## 10:          Jordan        NaN
## 11:           Korea -0.2517959
## 12:         Lebanon        NaN
## 13:          Mexico  0.3577465
## 14:     New Zealand        NaN
## 15:   United States        NaN
## 16:         Uruguay        NaN
## 17: B-S-J-G (China)        NaN
  1. Transform variables, specifically recode MISCED and FISCED from characters to numeric variables.
ParentEdu = c('MISCED', 'FISCED')
pisa[,
     (ParentEdu) := lapply(.SD, as.numeric), .SDcols = ParentEdu
     ][,
       .(class(MISCED),
         class(FISCED))]
## Warning in lapply(.SD, as.numeric): NAs introduced by coercion

## Warning in lapply(.SD, as.numeric): NAs introduced by coercion
##         V1      V2
## 1: numeric numeric